How can I check the time consumed and memory consumption of a PHP method called in one request? How can I check the time consumed and memory consumption of a PHP method called in one request?
Reply content:
How can I check the time consumed and memory consumption of a PHP method called in one request?
Function microtime_float () {list ($ usec, $ sec) = explode ("", microtime (); return (float) $ usec + (float) $ sec );} function test () {static $ num = 0; $ num ++; $ memory = memory_get_usage (); $ time_start = microtime_float (); // The operation procedure is slightly usleep (100 ); $ m = memory_get_usage ()-$ memory; // memory $ t = microtime_float ()-$ time_start; // time-consuming return [$ num, $ m, $ t];} test (); print_r (test (); Array ([0] => 3 [1] => 0 [2] => 0.00016498565673828)
Maybe you need this
Under configurationXdebug
+Kcachegrind
That's all.