/** * @test * @covers \Xicrow\PhpDebug\Timer::reset * @covers \Xicrow\PhpDebug\Timer::add * @covers \Xicrow\PhpDebug\Timer::custom * @covers \Xicrow\PhpDebug\Timer::getStats */ public function testGetStats() { Timer::reset(); $expected = 'Unknow item in with key: foo'; $result = Timer::getStats('foo'); $this->assertEquals($expected, $result); $timerName = 'Foo'; Timer::custom($timerName, 0.1, 0.2); $result = Timer::getStats($timerName); $this->assertContains($timerName, $result); $this->assertContains('100.0000 MS', $result); $timerName = 'Really, really, really, really, really, really, really, really, really, really, really, really, really long timer name'; Timer::custom($timerName, 0.1, 0.2); $result = Timer::getStats($timerName); $this->assertContains(substr($timerName, -20), $result); $this->assertContains('100.0000 MS', $result); }
for ($k = 1; $k <= 2; $k++) { Timer::start('Loop level 3'); Timer::stop(); } Timer::stop(); } Timer::stop(); } // Callback test Timer::callback(null, 'time'); Timer::callback(null, 'strpos', 'Hello world', 'world'); Timer::callback(null, 'array_sum', [1, 2, 3, 4, 5, 6, 7, 8, 9]); Timer::callback(null, 'array_rand', [1, 2, 3, 4, 5, 6, 7, 8, 9]); Timer::callback(null, 'min', [1, 2, 3, 4, 5, 6, 7, 8, 9]); Timer::callback(null, 'max', [1, 2, 3, 4, 5, 6, 7, 8, 9]); Timer::callback(null, ['Xicrow\\PhpDebug\\Debugger', 'getDebugInformation'], [1, 2, 3]); Timer::callback(null, function () { return false; }); // Custom test Timer::custom('5 seconds', time(), time() + 5); Timer::custom('5 minutes', time(), time() + 5 * 60); Timer::custom('5 hours ', time(), time() + 5 * 60 * 60); Timer::custom('5 days ', time(), time() + 5 * 60 * 60 * 24); Timer::custom('5 weeks ', time(), time() + 5 * 60 * 60 * 24 * 7); // Show all timers Timer::showAll(); ?> </body> </html>