CI_Profiler::_compile_benchmarks PHP Method

_compile_benchmarks() protected method

This function cycles through the entire array of mark points and matches any two points that are named identically (ending in "_start" and "_end" respectively). It then compiles the execution times for all points and returns it as an array
protected _compile_benchmarks ( ) : array
return array
    protected function _compile_benchmarks()
    {
        $profile = array();
        $output = array();
        foreach ($this->CI->benchmark->marker as $key => $val) {
            // We match the "end" marker so that the list ends
            // up in the order that it was defined
            if (preg_match("/(.+?)_end/i", $key, $match)) {
                if (isset($this->CI->benchmark->marker[$match[1] . '_end']) and isset($this->CI->benchmark->marker[$match[1] . '_start'])) {
                    $profile[$match[1]] = $this->CI->benchmark->elapsed_time($match[1] . '_start', $key);
                }
            }
        }
        // Build a table containing the profile data.
        // Note: At some point we might want to make this data available to be logged.
        foreach ($profile as $key => $val) {
            $key = ucwords(str_replace(array('_', '-'), ' ', $key));
            $output[$key] = $val;
        }
        unset($profile);
        return $output;
    }

Usage Example

Esempio n. 1
0
 protected function _compile_benchmarks()
 {
     $output = parent::_compile_benchmarks();
     foreach ($output as $benchmark => $time) {
         $output[$benchmark] = $this->milliseconds($time);
     }
     return $output;
 }