How to find out the time spent inside a PHP script?

I just want to know how much of the execution time is spent inside my script and how much is spent in library functions.

Use XDebug Profiler for it.


I'm guessing you want something like this:

<?php
// the whole operation
$time1 = time();

// perform some functions
$s = file_get_contents("somefilename");
$time2 = time();

// perform some library functions
$rs = some_third_party_library_function();
$time3 = time();

// Show results
echo "Overall Time spent: " . ($time3 - $time1) . "s <br>";
echo "Time spent reading file: ". ($time2 - $time1) . "s <br>";
echo "Time spent by Third Party Library: "  . ($time3 - $time2) . "s <br>";
?>

Tags:

Php