Skip to content

investigate slow tests / perf regression #13455

@staabm

Description

@staabm

Bug report

while running the test-suite recently I got the impression phpunit is not progressing further and it kind of hangs for a few seconds for the last tests ran. therefore I measured whats going on.

Running the testsuite without paratest and using Ergebnis\PHPUnit\SlowTestDetector\Extension leads:

Detected 23 tests where the duration exceeded the maximum duration.

 1. 00:05.424 (00:00.500) PHPStan\Analyser\AnalyserIntegrationTest::testBug12800
 2. 00:03.561 (00:00.500) PHPStan\Analyser\AnalyserIntegrationTest::testBug5081
 3. 00:03.226 (00:00.500) PHPStan\Reflection\SignatureMap\SignatureMapParserTest::testParseAll with data set #1 (80000)
 4. 00:02.464 (00:00.500) PHPStan\Analyser\AnalyserIntegrationTest::testBug9690
 5. 00:02.428 (00:00.500) PHPStan\Analyser\AnalyserIntegrationTest::testBug11283
 6. 00:02.279 (00:00.500) PHPStan\Analyser\AnalyserIntegrationTest::testBug11297
 7. 00:02.003 (00:00.500) PHPStan\Analyser\AnalyserIntegrationTest::testBug13352
 8. 00:01.900 (00:00.500) PHPStan\Analyser\AnalyserIntegrationTest::testBug10538
 9. 00:01.695 (00:00.500) PHPStan\Rules\Methods\ReturnTypeRuleTest::testBug8146bErrors
10. 00:01.624 (00:00.500) PHPStan\Analyser\AnalyserIntegrationTest::testBug7903

looking at PHPStan\Analyser\AnalyserIntegrationTest::testBug12800 by running it in isolation reveals we seem to be 40-50% slower:

from phpstan-src root:

cp tests/PHPStan/Analyser/data/bug-12800.php .

time php bin/phpstan analyze bug-12800.php --debug
Note: Using configuration file /Users/staabm/workspace/phpstan-src/phpstan.neon.dist.
/Users/staabm/workspace/phpstan-src/bug-12800.php
 ------ --------------------------------------------- 
  Line   bug-12800.php                                
 ------ --------------------------------------------- 
  5      Class Bug12800\a must be abstract or final.  
         🪪  phpstan.finalClass                       
 ------ --------------------------------------------- 


                                                                                                                        
 [ERROR] Found 1 error                                                                                                  
                                                                                                                        

php bin/phpstan analyze bug-12800.php --debug  5.65s user 0.16s system 99% cpu 5.815 total

at the time the test was added it ran in ~3 seconds

did not yet look further yet

Expected output

faster test

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions