Profiling and Optimizing PHPUnit

Sebastian Bergmann » 21 October 2007 » in PHPUnit » 5 Comments

Now that collecting code coverage information is not slow anymore (as of Xdebug 2.0.1), PHPUnit's report generation code (PHPUnit_Util_Report_*) has become a bottleneck.

Profiling PHPUnit's Report Generation

The image above shows the profile of PHPUnit's report generation code at revision 1473.

Profiling PHPUnit's Report Generation

The image above shows the profile of PHPUnit's report generation code at revision 1475, after I made the report a code coverage report only. The test result aspect of the previous report was not very usefull, made the report generation unneccassary complex and expensive, and should be handled by CruiseControl, for instance, anyways.

Profiling PHPUnit's Report Generation

The image above shows the profile of PHPUnit's report generation code at revision 1486, after I eliminated the PHPUnit_Util_Array::sortRecursively() method calls.

Profiling PHPUnit's Report Generation

The image above shows the profile of PHPUnit's report generation code at revision 1488, after I eliminated the PHPUnit_Util_Report_Node_File::tokenToColor() method calls.

Profiling PHPUnit's Report Generation

The image above shows the profile of PHPUnit's report generation code at revision 1533 with disabled syntax highlighting.

Profiling PHPUnit's Report Generation

The image above shows the profile of PHPUnit's report generation code at revision 1535 with the new statistics details.

Profiling PHPUnit's Report Generation

The image above shows the profile of PHPUnit's report generation code at revision 1586 after applying a set of performance patches by Hubert Roksor.

Profiling PHPUnit's Report Generation

The image above shows the profile of PHPUnit's report generation code at revision 1603 after applying another set of performance patches by Hubert Roksor.

Trackback specific URI for this entry

5 Comments to "Profiling and Optimizing PHPUnit"

Display comments as (Linear | Threaded)
  1. Sebastian
    22/10/2007 at 11:14 Permalink
    The relative numbers are nice, but which impact did these changes have on the absolute time required for generating the reports?

    Reply

  2. Sebastian Bergmann
    24/10/2007 at 07:03 Permalink
    For the Template component from the eZ Components the time to generate the report dropped from 4 minutes to 30 seconds.

    Reply

  3. René Leonhardt
    22/10/2007 at 11:29 Permalink
    Dear Sebastian,

    good job, as always!

    What tool did you use to generate the profiling graphs?


    Greetings from Germany,
    René

    Reply

  4. Sebastian Bergmann
    23/10/2007 at 08:47 Permalink
    Xdebug's profiler to get the raw data and KCachegrind to mine/visualize it.

    Reply

  5. Bjarte S. Karlsen
    22/10/2007 at 15:15 Permalink
    Very nice work Sebastian! The new features of 3.2 are very useful and speeding up the coverage reporting even further is very nice :)

    Reply

2 Trackbacks to "Profiling and Optimizing PHPUnit"

  1. /dev/weblog 23/10/2007 at 19:29
    Taking note of blog entries from Derek Rethans and Sebastian Bergmann about speed improvements to PHPUnit's use of Xdebug for code coverage analysis, I obtained the latest copies of each. Running the full code coverage report for all Xyster tests used to
  2. Sebastian Bergmann 27/11/2008 at 10:40
    Some of PHPUnit features come with the cost of a performance penality. This posting explores the effect of the --no-syntax-check, $backupGlobals = FALSE;, and --coverage-html options. Syntax Check: disabled, $GLOBALS Backup: disabled, Code Coverage: disa

Add Comment


To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Submitted comments will be subject to moderation before being displayed.