PHP profiling delay before shutting down

// VERY BEGIN OF SCRIPT
$_SERVER['HX_startTime'] = microtime(true);

...

// MY SHUTDOWN FUNCTION
register_shutdown_function('HX_shutdownFn');
function HX_shutdownFn()
{
    // formatTimeSpan is simple time to string conversion function
    var_dump(formatTimeSpan(microtime(true) - $_SERVER['HX_startTime']));
}


...

// VERY END OF SCRIPT
var_dump(formatTimeSpan(microtime(true) - $_SERVER['HX_startTime']));

I have 0.0005s . at the end of the script and 1.1s . when turned off. This is normal? Where is 1 second lost?

Script is pure php, does not use db connection, etc. Testing on the WAMP server (php v 5.3.9, apache 2.2.21)

+5
source share
3 answers

I assume that there will be more code than you sent - in this case, if you pass any output to the client, the script will not be disabled until it is sent.

Additional shutdown functions may also be logged that you might not be aware of, as indicated in the comments.

, script ( , , ...), -. .

0

- . , , .

, DEBUGGING, .

. . script .

0

, . , , ( ).

XDebug (http://xdebug.org/), . XDebug XDEBUG_TRACE = 1 URL- , .

, , . .

, XDebug:

xdebug.default_enable=1
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=1
xdebug.profiler_append=On
xdebug.auto_trace=Off
xdebug.show_mem_delta=On
xdebug.collect_return=On
xdebug.collect_params=4
xdebug.profiler_output_dir = /tmp
xdebug.profiler_output_name = profile.%H.%t.%p
xdebug.var_display_max_children = 999
xdebug.var_display_max_data = 99999
xdebug.var_display_max_depth = 100
xdebug.remote_enable=1
xdebug.cli_color=1
xdebug.show_local_vars=1    
xdebug.show_mem_delta=1
xdebug.collect_return=1
xdebug.collect_assignments=1
xdebug.collect_params=4
xdebug.collect_includes=1
xdebug.trace_enable_trigger=1
xdebug.trace_output_dir=/tmp
xdebug.trace_output_name=trace.%t.%R.%p
0

All Articles