Пример #1
0
    public function testSection()
    {
        $stopwatch = new Stopwatch();

        $stopwatch->startSection();
        $stopwatch->start('foo', 'cat');
        $stopwatch->stop('foo');
        $stopwatch->start('bar', 'cat');
        $stopwatch->stop('bar');
        $stopwatch->stopSection(1);

        $stopwatch->startSection();
        $stopwatch->start('foobar', 'cat');
        $stopwatch->stop('foobar');
        $stopwatch->stopSection(2);

        // the section is an event by itself
        $this->assertEquals(3, count($stopwatch->getSectionEvents(1)));
        $this->assertEquals(2, count($stopwatch->getSectionEvents(2)));
    }
Пример #2
0
 public function testReopenASection()
 {
     $stopwatch = new Stopwatch();
     $stopwatch->openSection();
     $stopwatch->start('foo', 'cat');
     $stopwatch->stopSection('section');
     $stopwatch->openSection('section');
     $stopwatch->start('bar', 'cat');
     $stopwatch->stopSection('section');
     $events = $stopwatch->getSectionEvents('section');
     $this->assertCount(3, $events);
     $this->assertCount(2, $events['__section__']->getPeriods());
 }
Пример #3
0
 public function testSection()
 {
     $stopwatch = new Stopwatch();
     $stopwatch->startSection();
     $stopwatch->start('foo', 'cat');
     $stopwatch->stop('foo');
     $stopwatch->start('bar', 'cat');
     $stopwatch->stop('bar');
     $stopwatch->stopSection('1');
     $stopwatch->startSection();
     $stopwatch->start('foobar', 'cat');
     $stopwatch->stop('foobar');
     $stopwatch->stopSection('2');
     $stopwatch->startSection();
     $stopwatch->start('foobar', 'cat');
     $stopwatch->stop('foobar');
     $stopwatch->stopSection('0');
     // the section is an event by itself
     $this->assertCount(3, $stopwatch->getSectionEvents('1'));
     $this->assertCount(2, $stopwatch->getSectionEvents('2'));
     $this->assertCount(2, $stopwatch->getSectionEvents('0'));
 }