Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7827921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:05:51+00:00 2026-06-02T10:05:51+00:00

I am using XDebug as a profiler for a PHP application. I have run

  • 0

I am using XDebug as a profiler for a PHP application. I have run into a situation where XDebug changes severely the results in such a degree that they are useless.

Here a simplified example to demonstrate the problem:

function foo(){ $x = 1; }
function bar(){ foo(); }

Test A:

$t0 = microtime(true);
for ($i = 0; $i < 1000000; $i++) foo();
echo microtime(true) - $t0;

Test B:

$t0 = microtime(true);
for ($i = 0; $i < 1000000; $i++) bar();
echo microtime(true) - $t0;

So, these are the results I am getting (in seconds):

          profiler  | profiler  > profiler
          disabled  | enabled   > results
          --------------------------------------------------------------------
          output    | output    > total time   time in foo()   time in bar()
Test A    0.159     | 12.199    > 12.245       0.110           - (not called)
Test B    0.233     | 25.399    > 25.578       0.104           11.068

The increased execution time is expected because of the extra calls to the profiler. The slight variation between the microtime-based output and the profiler results is also expected. I have repeated the tests several times, and the results are always similar.

From the results taken from Test B with the profiler disabled, we can say that the script spends about 0.159 seconds in foo() and 0.074 seconds in bar(). It is evident that time spent in bar() is less than the time spent in foo().

However, when I analyze the results of the profiler (with qcachegrind), the time shown as spent in bar() (= 11.068 seconds) is ridiculously higher than the time in foo() (=0.104 seconds). There is a possible explanation for this: each time a function call is made, the profiler runs some extra code to keep track of the time spent in the call. I believed that it excluded this extra time from the results, but apparently it does not.

[EDIT]
As a result, the profiler says that bar() takes more time than foo() in this program, which is not the case as we have measured with the profiler disabled. It’s not even close! The relative results (the percentage of time taken by each function) are totally wrong. This should not be expected, because, if this is the case, the profiler can not indicate which function takes most of the time. Although the absolute times are expected to have (big) differences, the relative times should not have.
[/EDIT]

This renders the results unusable. Any code that is more modular (with more function calls, wrappers, objects etc.) is severely penalized, although it is not that slower!

So the question is: Is there any way to tell XDebug to ignore or track separately the extra time spent for the profiler calls?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T10:05:52+00:00Added an answer on June 2, 2026 at 10:05 am

    Unfortunatelly, it is not possible. I am no longer using XDebug as a profiler and I suggest that nobody should use it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Eclipse and XDebug to develop a PHP application that relies on web
When using Eclipse PDT with XDebug to debug a PHP web application, is there
Is there free and good line-level profiler for PHP? I'm using xdebug and it's
I'm using NetBeans 6.5 for developing PHP and I have xdebug setup. Is there
I am using xdebug with my php methods such as var_dump() are beautiful but
I've been using xdebug to debug and understand code in php projects for a
I'm having trouble with debugging a PHP project through NetBeans using XDebug, and was
I'm using Exlipse with Xdebug to debug my php codes, which works well. But
Currently, I am using xdebug profiler & KCacheGrind . But GallGrind format does not
any suggestions for good php debuggers, which are not bloated? i tried using xdebug

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.