DebugKit\DebugTimer::getAll PHP Méthode

getAll() public static méthode

Calculates elapsed time for each timer. If clear is true, will delete existing timers
public static getAll ( boolean $clear = false ) : array
$clear boolean false
Résultat array
    public static function getAll($clear = false)
    {
        $start = self::requestStartTime();
        $now = microtime(true);
        $times = [];
        if (!empty(self::$_timers)) {
            $firstTimer = reset(self::$_timers);
            $_end = $firstTimer['start'];
        } else {
            $_end = $now;
        }
        $times['Core Processing (Derived from $_SERVER["REQUEST_TIME"])'] = ['message' => __d('debug_kit', 'Core Processing (Derived from $_SERVER["REQUEST_TIME"])'), 'start' => 0, 'end' => $_end - $start, 'time' => round($_end - $start, 6), 'named' => null];
        foreach (self::$_timers as $name => $timer) {
            if (!isset($timer['end'])) {
                $timer['end'] = $now;
            }
            $times[$name] = array_merge($timer, ['start' => $timer['start'] - $start, 'end' => $timer['end'] - $start, 'time' => self::elapsedTime($name)]);
        }
        if ($clear) {
            self::$_timers = [];
        }
        return $times;
    }

Usage Example

 /**
  * Test save timers
  *
  * @return void
  */
 public function testSaveTimers()
 {
     $timers = DebugTimer::getAll();
     $this->assertEquals(count($timers), 1);
     $article = $this->Article->newEntity(['user_id' => 1, 'title' => 'test', 'body' => 'test']);
     $this->Article->save($article);
     $result = DebugTimer::getAll();
     $this->assertEquals(count($result), 2);
 }
All Usage Examples Of DebugKit\DebugTimer::getAll