Beispiel #1
0
 /**
  * @test
  * @covers \Xicrow\PhpDebug\Timer::reset
  * @covers \Xicrow\PhpDebug\Timer::add
  * @covers \Xicrow\PhpDebug\Timer::start
  * @covers \Xicrow\PhpDebug\Timer::stop
  */
 public function testStop()
 {
     Timer::reset();
     $expected = 0;
     $result = count(Timer::$collection);
     $this->assertEquals($expected, $result);
     $expected = null;
     $result = Timer::stop();
     $this->assertEquals($expected, $result);
     $expected = 0;
     $result = count(Timer::$collection);
     $this->assertEquals($expected, $result);
     $expected = 'test';
     $result = Timer::start('test');
     $this->assertEquals($expected, $result);
     $expected = 'test';
     $result = Timer::stop('test');
     $this->assertEquals($expected, $result);
     $expected = 1;
     $result = count(Timer::$collection);
     $this->assertEquals($expected, $result);
 }
Beispiel #2
0
Timer::start('Total');
// No name test
Timer::start();
Timer::stop();
// Loop test
for ($i = 1; $i <= 2; $i++) {
    Timer::start('Loop level 1');
    for ($j = 1; $j <= 2; $j++) {
        Timer::start('Loop level 2');
        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);