In the CI framework, the Benchmark test class Benchmark. php is used to calculate the time difference between any two mark points. & Amp; lt ;? Phpif (! Defined ('basepath') exit ('nodirectscri
In the CI framework, the Benchmark test class Benchmark. php is used to calculate the time difference between any two mark points.
Marker [$ name] = microtime ();}/*** calculate the running time between any two points */function elapsed_time ($ point1 = '', $ point2 = '', $ decimals = 4) {if ($ point1 = '') {return '{elapsed_time}';} if (! Isset ($ this-> marker [$ point1]) {return '';} if (! Isset ($ this-> marker [$ point2]) {$ this-> marker [$ point2] = microtime () ;}// use list () is also inevitable, because the microtime () function returns a string in the format of "msec sec", that is, the number of microseconds and the number of seconds. list ($ sm, $ ss) = explode ('', $ this-> marker [$ point1]); list ($ em, $ es) = explode ('', $ this-> marker [$ point2]); return number_format ($ em + $ es)-($ sm + $ ss), $ decimals);} function memory_usage () {return '{memory_usage }';}}
You can use this Benchmark to test PHP performance in your own program.