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))); }
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')); }
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()); }
public function testStopwatchSections() { $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), $stopwatch = new Stopwatch()); $kernel = $this->getHttpKernel($dispatcher, function () { return new Response(); }); $request = Request::create('/'); $response = $kernel->handle($request); $kernel->terminate($request, $response); $events = $stopwatch->getSectionEvents($response->headers->get('X-Debug-Token')); $this->assertEquals(array( '__section__', 'kernel.request', 'kernel.request.loading', 'kernel.controller', 'kernel.controller.loading', 'controller', 'kernel.response', 'kernel.response.loading', 'kernel.terminate', 'kernel.terminate.loading', ), array_keys($events)); }