Last active
September 18, 2018 12:57
-
-
Save docteurklein/534fc94a93e654d76a9c7e377aa5c07d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$num = floatval($argv[1] ?? '1e6'); | |
echo "iterations: $num\n"; | |
function noop() { | |
} | |
$start = microtime(true); | |
printf("starting raw at:\t\t%.3F s\n", $start); | |
for ($i=0; $i < $num; $i++) { | |
noop(); | |
} | |
$duration = microtime(true) - $start; | |
tideways_xhprof_enable(TIDEWAYS_XHPROF_FLAGS_MEMORY | TIDEWAYS_XHPROF_FLAGS_CPU); | |
$start_p = microtime(true); | |
printf("starting profiling at: \t\t%.3F s\n", $start_p); | |
for ($i=0; $i < $num; $i++) { | |
noop(); | |
} | |
$duration_p = microtime(true) - $start_p; | |
tideways_xhprof_disable(); | |
printf("raw:\t\t%d µs\n", $duration * 1e6); | |
printf("profiler:\t%d µs\n", $duration_p * 1e6); | |
printf("total overhead:\t%d µs (x%.2F)\n", ($duration_p - $duration) * 1e6, $duration_p / $duration); | |
printf("avg overhead:\t%.3F µs\n", (($duration_p - $duration) / $num) * 1e6); |
Author
docteurklein
commented
Sep 18, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment