示例#1
0
 /**
  * @test
  * @covers \Xicrow\PhpDebug\Timer::formatForUnits
  * @covers \Xicrow\PhpDebug\Timer::formatMiliseconds
  */
 public function testFormatMiliseconds()
 {
     $expected = '500.00 MS';
     $result = Timer::formatMiliseconds(500, 2, 'MS');
     $this->assertEquals($expected, $result);
     $expected = '5000.00 MS';
     $result = Timer::formatMiliseconds(5000, 2, 'MS');
     $this->assertEquals($expected, $result);
     $expected = '5.00 S ';
     $result = Timer::formatMiliseconds(5 * 1000, 2);
     $this->assertEquals($expected, $result);
     $expected = '5.00 M ';
     $result = Timer::formatMiliseconds(5 * 1000 * 60, 2);
     $this->assertEquals($expected, $result);
 }
示例#2
0
        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>