View Issue Details

IDProjectCategoryView StatusLast Update
0002362XdebugProfilingpublic2025-08-27 15:47
Reporterarshidkv12 Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionno change required 
PlatformMacOSMacOS Version24.6.0 Darwin
Summary0002362: Wrong time info in KCashGrind
Description

Profile displays incorrect time. I disabled the garbage collector.

Steps To Reproduce

Add following code.

php.ini
zend.enable_gc = Off
[xdebug]
zend_extension="xdebug.so" ; Path to the Xdebug extension
xdebug.mode=profile ; Enable only profiling (no step debugger)
xdebug.start_with_request=yes ; Do not start profiling automatically on every request
xdebug.output_dir="/Users/arshid/Desktop/test/out" ; Directory to store cachegrind/profile files
xdebug.profiler_output_name="cachegrind.out.%p" ; File name pattern (%p = PID)

<?php //test.php
function a1(){
str_replace("a", '-', "dfdsfaa,aaaadfgfg,fdfdfdfdfdfddfdfdfdfdfdf");
str_replace("ad", '-', "dfdsfaa,aaaadfgfg,fdfdfdfdfdfddfdfdfdfdfdf");
}

function a2(){
str_replace("a", '-', "dfda");
}
a2();
a1();

Additional Information

Expecting a1() will use more time. But getting a2() takes more time.

TagsNo tags attached.
Operating SystemMac
PHP Version8.4-dev

Activities

derick

2025-08-27 15:47

administrator   ~0007349

Last edited: 2025-08-27 15:47

I can reproduce this, but also without Xdebug or the profiler even loaded.

When I run this script:

<?php //test.php
function a1(){
str_replace("a", '-', "dfdsfaa,aaaadfgfg,fdfdfdfdfdfddfdfdfdfdfdf");
str_replace("ad", '-', "dfdsfaa,aaaadfgfg,fdfdfdfdfdfddfdfdfdfdfdf");
}

function a2(){
str_replace("a", '-', "dfda");
}

echo microtime(), "\n";
a2();
echo microtime(), "\n";
a1();
echo microtime(), "\n";

I get:

0.20297800 1756309224
0.20301000 1756309224
0.20301500 1756309224

ie, 32µs vs 5µs, also ~ 6 times as much.