Skip to content
veloper edited this page Oct 28, 2010 · 5 revisions

Statistics

Basic Example

Getting The Statistics Array /** * Sample request using Bench */ Bench::start(); // [Application Bootstrap] Bench::mark('bootstrap'); // [Database Connection Opened] Bench::mark('database'); // [Data Processing + Manipulation] Bench::mark('processing'); // [HTML Creation] Bench::mark('html'); // [Misc Code] Bench::stop();

 /**
  * Getting Request Statistics
  */
print_r(Bench::getStats()); // ->
    Array (
         // The average time between marks (in seconds)
         [mark_average] => 0.346896330516
         // The longest mark
         [mark_longest] => Array
             (
                 [id] => database
                 [microtime] => 1288045989.62
                 [since_start] => 1.02174592018
                 [since_last_mark] => 0.831446886063
             )
         // The shortest mark
         [mark_shortest] => Array
             (
                 [id] => processing
                 [microtime] => 1288045989.64
                 [since_start] => 1.04068899155
                 [since_last_mark] => 0.0189430713654
             )
         // Start microtime
         [start] => 1288060408.82
         // Stop microtime (if called)
         [stop] => 1288060409.95             
         // Time elapsed (in seconds)
         [elapsed] => 1.0407409668
     )

Advanced Examples

getStats()

This method reflects the statistics of Bench at the time it was called. That means getStats() can be called at anytime (and multiple times) after Bench::start() has been called and each time the statistics array will be different.

Clone this wiki locally