phpunit-speedtrap icon indicating copy to clipboard operation
phpunit-speedtrap copied to clipboard

Output could contain convenient way to run/view slow test using a profiler

Open johnkary opened this issue 5 years ago • 1 comments

After a developer discovers a slow test using SpeedTrap, they want to discover why the test is slow, and eventually change the code to run faster. SpeedTrap cannot profile code deeper than the start and stop time of each test. But SpeedTrap might make it easier for a developer to use another tool to discover why their test is slow.

What if the PHPUnit SpeedTrap report contained output that conveniently let the reader run or view a PHP profiler's analysis of the slow test?

For example, as a developer, I run my test suite locally on my development machine with SpeedTrap enabled. The test output shows the test UserLoginTest::testLoginWorkflow() takes 6 seconds to execute. I am curious why this test is so slow! A profiler would allow me to see clock time, wall time, CPU usage, memory usage, etc. of this code's execution path. How could SpeedTrap help me more quickly profile this slow test?

Blackfire.io is likely the most feature-rich PHP profiler available. It can run on a developer's local machine. This is important so the profiling occurs under the same conditions as the slow test run found with SpeedTrap.

  • Could SpeedTrap detect that Blackfire is available to use?
  • If yes to above, could the test output display a CLI command to re-execute the slow test wrapped in a Blackfire profiler session?
  • Could SpeedTrap web link to a previous Blackfire run that executed the slow test? (Is that even useful?)

Please use the comments for any additional ideas, questions or answers to how this feature might work.

johnkary avatar Jul 13 '18 17:07 johnkary

Discussion with Blackfire devs began here: https://twitter.com/romainneutron/status/1019198786785173504

Blackfire PHP-SDK: https://blackfire.io/docs/reference-guide/php-sdk#installation Also has some PHPUnit integration: https://blackfire.io/docs/integrations/phpunit

johnkary avatar Jul 17 '18 15:07 johnkary