longxinH / xhprof

PHP7/PHP8 support
http://pecl.php.net/package/xhprof
Apache License 2.0
1.04k stars 165 forks source link

Does major performance impact? #65

Open iNiSiRe opened 2 years ago

iNiSiRe commented 2 years ago
<?php

$enableProfiling = $_ENV['ENABLE_PROFILING'] ?? false;

if ($enableProfiling) {
    xhprof_enable();
}

$start = microtime(true);

$test = 'abcd';

for ($i = 0; $i < 1_000_000; $i++) {
    $test = md5($test);
}

echo sprintf('Elapsed: %f', microtime(true) - $start) . PHP_EOL;

if ($enableProfiling) {
    xhprof_disable();
}

ENABLE_PROFILING=1 php ./bin/test.php Elapsed: 9.300184

ENABLE_PROFILING=0 php ./bin/test.php Elapsed: 0.386227

I did something wrong or it's normal behaviour?

PHP 8.0/7.3, xhprof 2.3.5.

longxinH commented 2 years ago

Yes, added a hook to zend, so it will affect performance