Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Performance report to measure sniff run time performance #3810

Commits on May 20, 2023

  1. Util\Timing: split printRunTime() method

    ... into logical parts to allow the Performance report access to the total run time information (at the point of report creation) as well.
    jrfnl committed May 20, 2023
    Configuration menu
    Copy the full SHA
    f73c47d View commit details
    Browse the repository at this point in the history
  2. File: add getListenerTimes() method

    ... to allow for access to the recorded listener times from within a report class.
    jrfnl committed May 20, 2023
    Configuration menu
    Copy the full SHA
    9d05a82 View commit details
    Browse the repository at this point in the history
  3. Config: add trackTime toggle for whether or not to track listener t…

    …imes
    
    As recording the time taken by each sniff has a performance impact in and of itself on a CS run, only record the time taken by each sniff when needed. [*]
    
    Originally, this was already done conditionally based on the `PHP_CODESNIFFER_VERBOSITY > 2` condition.
    However, adding the Performance report would add a second criteria.
    
    This commit adds a new (internal) Config setting `trackTime`, which will be set to `true` when `PHP_CODESNIFFER_VERBOSITY > 2`.
    
    This commit paves the way for adding the second criteria in the next commit.
    
    ---
    
    [*] I've done some unscientific benchmarks for this by running PHPCS multiple times, with and without tracking the listener times, over a 300+ file codebase.
    Without tracking listener times, the run time was always around 39 seconds with 56Mb memory use.
    With tracking listener times, the run time was always around 54 seconds with 64Mb memory use.
    
    This, to me, shows a significant enough difference and sufficient reason to put this toggle in place to only track time when needed.
    jrfnl committed May 20, 2023
    Configuration menu
    Copy the full SHA
    b9d7f9e View commit details
    Browse the repository at this point in the history
  4. New Performance report to measure sniff run time performance

    The report will print the sniff name, cumulative listener run time and % of the total sniff run time for each sniff triggered during a run.
    
    The report is order by cumulative listener run time in descending order.
    
    Additionally, it will highlight sniffs which have a cumulative listener run time more than twice the average run time per sniff in orange and sniffs with a cumulative listener run time of more than three times the average run time per sniff in red.
    
    At the bottom of the report it will also compare the total sniff relative run time with the total run time.
    
    Fixes 3784
    
    Includes mention of the report in the CLI help test.
    jrfnl committed May 20, 2023
    Configuration menu
    Copy the full SHA
    109cddc View commit details
    Browse the repository at this point in the history