public function calculateTimings($messages)
    {
        $timings = [];
        $stack = [];

        foreach ($messages as $i => $log) {
            list($token, $level, $category, $timestamp, $traces) = $log;
            $log[5] = $i;
            if ($level == Logger::LEVEL_PROFILE_BEGIN) {
                $stack[] = $log;
            } elseif ($level == Logger::LEVEL_PROFILE_END) {
                if (($last = array_pop($stack)) !== null && $last[0] === $token) {
                    $timings[$last[5]] = [
                        'info' => $last[0],
                        'category' => $last[2],
                        'timestamp' => $last[3],
                        'trace' => $last[4],
                        'level' => count($stack),
                        'duration' => $timestamp - $last[3],
                    ];
                }
            }
        }

        ksort($timings);

        return array_values($timings);
    }
public function calculateTimings($messages)
    {
        $timings = [];
        $stack = [];

        foreach ($messages as $i => $log) {
            list($token, $level, $category, $timestamp, $traces) = $log;
            $log[5] = $i;
            if ($level == Logger::LEVEL_PROFILE_BEGIN) {
                $stack[] = $log;
            } elseif ($level == Logger::LEVEL_PROFILE_END) {
                if (($last = array_pop($stack)) !== null && $last[0] === $token) {
                    $timings[$last[5]] = [
                        'info' => $last[0],
                        'category' => $last[2],
                        'timestamp' => $last[3],
                        'trace' => $last[4],
                        'level' => count($stack),
                        'duration' => $timestamp - $last[3],
                    ];
                }
            }
        }

        ksort($timings);

        return array_values($timings);
    }
public function calculateTimings ( $ messages ) { $ timings = [ ] ; $ stack = [ ] ; foreach ( $ messages as $ i => $ log ) { list ( $ token , $ level , $ category , $ timestamp , $ traces ) = $ log ; $ log [ 5 ] = $ i ; if ( $ level == Logger :: LEVEL_PROFILE_BEGIN ) { $ stack [ ] = $ log ; } elseif ( $ level == Logger :: LEVEL_PROFILE_END ) { if ( ( $ last = array_pop ( $ stack ) ) !== null && $ last [ 0 ] === $ token ) { $ timings [ $ last [ 5 ] ] = [ 'info' => $ last [ 0 ] , 'category' => $ last [ 2 ] , 'timestamp' => $ last [ 3 ] , 'trace' => $ last [ 4 ] , 'level' => count ( $ stack ) , 'duration' => $ timestamp - $ last [ 3 ] , ] ; } } } ksort ( $ timings ) ; return array_values ( $ timings ) ; }
Calculates the elapsed time for the given log messages.
@param array $messages the log messages obtained from profiling
@return array timings. Each element is an array consisting of these elements:
`info`, `category`, `timestamp`, `trace`, `level`, `duration`.
Calculates the elapsed time for the given log messages .