Benchmarking PHP page load times

前端 未结 10 2228
借酒劲吻你
借酒劲吻你 2021-01-31 10:56

How could I measure the time taken to load a page (with various different PHP statements)?

Somewhat like the stats available here - http://talks.php.net/show/drupal08/24

10条回答
  •  自闭症患者
    2021-01-31 11:17

    Try https://github.com/fotuzlab/appgati

    It allows to define steps in the code and reports time, memory usage, server load etc between two steps.

    Something like:

        $appgati->Step('1');
    
        // Do some code ...
    
        $appgati->Step('2');
    
        $report = $appgati->Report('1', '2');
        print_r($report);
    

    Sample output array:

    Array
    (
        [Clock time in seconds] => 1.9502429962158
        [Time taken in User Mode in seconds] => 0.632039
        [Time taken in System Mode in seconds] => 0.024001
        [Total time taken in Kernel in seconds] => 0.65604
        [Memory limit in MB] => 128
        [Memory usage in MB] => 18.237907409668
        [Peak memory usage in MB] => 19.579357147217
        [Average server load in last minute] => 0.47
        [Maximum resident shared size in KB] => 44900
        [Integral shared memory size] => 0
        [Integral unshared data size] => 0
        [Integral unshared stack size] => 
        [Number of page reclaims] => 12102
        [Number of page faults] => 6
        [Number of block input operations] => 192
        [Number of block output operations] => 
        [Number of messages sent] => 0
        [Number of messages received] => 0
        [Number of signals received] => 0
        [Number of voluntary context switches] => 606
        [Number of involuntary context switches] => 99
    )
    

提交回复
热议问题