|
12 | 12 | * [JSON](#printing-a-json-report)
|
13 | 13 | * [JUnit](#printing-a-junit-report)
|
14 | 14 | * Notify-Send
|
| 15 | + * [Performance](#printing-a-performance-report) |
15 | 16 | * [Source](#printing-a-source-report)
|
16 | 17 | * [SVN Blame](#printing-an-svn-blame-report)
|
17 | 18 | * [XML](#printing-an-xml-report)
|
@@ -441,6 +442,47 @@ PHP_CodeSniffer can output an XML report similar to the one produced by JUnit, a
|
441 | 442 | <p align="right"><a href="#table-of-contents">back to top</a></p>
|
442 | 443 |
|
443 | 444 |
|
| 445 | +## Printing a Performance Report |
| 446 | +PHP_CodeSniffer can output a sniff performance report showing you which sniffs in the standard you use are _slowest_. This can be useful information to examine when a PHP_CodeSniffer run takes a long time to finish and will provide you with insights to share with the developers of the sniffs you use. |
| 447 | + |
| 448 | +When the `--colors` option is enabled, sniffs which take more than twice the average run time per sniff will be displayed in orange and sniffs with a cumulative listener run time of more than three times the average run time per sniff will display in red. |
| 449 | + |
| 450 | +> [!NOTE] |
| 451 | +> Enabling the performance report, in and of itself will make a PHP_CodeSniffer run slower. This is nothing to worry about as the exact time taken for each sniff isn't that relevant, it's the relative time taken _in comparison to other sniffs_ which is the interesting part. |
| 452 | +
|
| 453 | +> [!NOTE] |
| 454 | +> A sniff being "slow" can be due to the complexity of the sniff, in which case, this is to be expected. |
| 455 | +> Also keep in mind that the sniff run-time will often be influenced by whether or not the sniff finds errors in your code. |
| 456 | +
|
| 457 | +To print a performance report, use the `--report=performance` command line argument. The output will look like this: |
| 458 | + |
| 459 | + $ phpcs --report=performance /path/to/code |
| 460 | + |
| 461 | + PHP CODE SNIFFER SNIFF PERFORMANCE REPORT |
| 462 | + -------------------------------------------------------------------------------- |
| 463 | + SNIFF TIME TAKEN (SECS) (%) |
| 464 | + -------------------------------------------------------------------------------- |
| 465 | + Generic.NamingConventions.UpperCaseConstantName 0.074654 ( 44.6 %) |
| 466 | + PSR1.Files.SideEffects 0.028242 ( 16.9 %) |
| 467 | + PSR1.Methods.CamelCapsMethodName 0.027005 ( 16.2 %) |
| 468 | + PSR1.Classes.ClassDeclaration 0.021653 ( 13.0 %) |
| 469 | + Squiz.Classes.ValidClassName 0.010412 ( 6.2 %) |
| 470 | + Generic.PHP.DisallowAlternativePHPTags 0.002662 ( 1.6 %) |
| 471 | + Generic.PHP.DisallowShortOpenTag 0.002560 ( 1.5 %) |
| 472 | + Generic.Files.ByteOrderMark 0.000012 ( 0.0 %) |
| 473 | + -------------------------------------------------------------------------------- |
| 474 | + TOTAL SNIFF PROCESSING TIME 0.167201 (100.0 %) |
| 475 | + |
| 476 | + -------------------------------------------------------------------------------- |
| 477 | + Time taken by sniffs 0.167201 ( 1.2 %) |
| 478 | + Time taken by PHPCS runner 13.336752 ( 98.8 %) |
| 479 | + -------------------------------------------------------------------------------- |
| 480 | + TOTAL RUN TIME 13.503953 (100.0 %) |
| 481 | + -------------------------------------------------------------------------------- |
| 482 | + |
| 483 | +<p align="right"><a href="#table-of-contents">back to top</a></p> |
| 484 | + |
| 485 | + |
444 | 486 | ## Printing an SVN Blame Report
|
445 | 487 | Like the Git Blame report, PHP_CodeSniffer can make use of the `svn blame` command to try and determine who committed each error and warning to an SVN repository. To print an SVN Blame report, use the `--report=svnblame` command line argument. The output and options are the same as those described in the [Git Blame report](#printing-a-git-blame-report).
|
446 | 488 |
|
|
0 commit comments