Php:
It is usually the beginning of the code you want to check to record a time, the end of the record a time. Take the difference value,
the efficiency of database SQL
SQL explain (MySQL), enable slow query log to record slow queries.
Usually also depends on the database design is reasonable, the demand is reasonable and so on.
But this time is generally very fast, in less than a second, so you can not directly use mktime ()function Getmicrotime () {
List ($usec, $sec) = Explode ("", Microtime ());
$num = ((float) $usec + (float) $sec);
Return sprintf ("%.4f", $num);
}
Usage:
$t _start = Getmicrotime ();
here, put the code you want to check.
$t _end = Getmicrotime ();
echo $t _end-$t _start;
The units of the output are seconds, and"%.4f" represents the exact four digits after the decimal point, which can be changed by itself
How do you check the efficiency of the PHP script execution (usually the script execution time) and the efficiency of the database SQL (usually the database query time) and locate and analyze the bottleneck of script execution and database query?