Skip to content

Stop the simulation after the benchmark's span - #5

Merged
ondrejmirtes merged 1 commit into
1.xfrom
stop-instrumentation
Nov 14, 2026
Merged

ondrejmirtes merged 1 commit into
1.xfrom
stop-instrumentation

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

Since #4, the counter starts Callgrind's instrumentation once per case. Until now it then stayed on through the #[After] methods and the end of the process, such as PHPStan freeing its container, which all ran under the cache simulation. phpstan-src's slowest shard went from 17 to 23.5 minutes, part of which is a slower benchmark of its own.

Counter::finish() is the counterpart of prepare(). CaseRunner calls it after the benchmark's span, also when the benchmark throws, and CodSpeedCounter then stops the instrumentation through the new Tally\Hooks\stop_instrumentation() of tally_hooks 1.2.0.

The counts stay the same. Locally on PHP 8.5.12, WarmupBench gave the same instructions within a few under 1.x and this branch, and so did phpstan-src's bug-1388.php (593.25M). That case took 31 s instead of 34 s in total, including the native run.

Since the counter started the instrumentation once for the whole case, the
after methods and the end of the process ran under Callgrind's cache
simulation too, such as PHPStan freeing its container. The counter now stops
the instrumentation after the last span, also when the benchmark throws. The
counts stay the same; analysing bug-1388.php in PHPStan's benchmarks took 31
instead of 34 seconds.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1d73a-bab0-7223-9245-50c2c00f22c7
@ondrejmirtes
ondrejmirtes merged commit 6a2f946 into 1.x Nov 14, 2026
27 checks passed
@ondrejmirtes
ondrejmirtes deleted the stop-instrumentation branch November 14, 2026 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant