PHP log / graph runtime

Are there any tools for registering page load time for php site?

Basically, something that I see loading time trends over time, I thought about dumping them to a file using error_log (), but I don’t know what I can use to analyze it and display graphs

+3
source share
3 answers

You can write microtime at the beginning of execution, hold this variable to the end, check the time, subtract them, and there you have the runtime. Output buffering will be necessary to do this work in most cases, unless the situation in which a particular thing always works last (for example, footer()).

$time_start = microtime_float();

function microtime_float() {
   list($usec, $sec) = explode(" ", microtime());
   return ((float)$usec + (float)$sec);
}

//at the start. 

//at the end:

$time_end = microtime_float();
$time = round($time_end - $time_start, 4);

echo "Last uncached content render took $time seconds";
+6

Firebug Firefox, Net, .

, apache apache bench, ab --help .

+3

See PEAR Test . It allows you to add tests to your code. You can force it to dump the HTML table on its pages, or you can scroll through the data and write to the log file.

0
source

Source: https://habr.com/ru/post/1697520/


All Articles