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 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 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')); }
/** * A convenience function for logging a debug event. * * @param mixed $message the message to log. */ public function debug($message) { $add = true; if (null !== $this->stopwatch) { $trace = debug_backtrace(); $method = $trace[2]['args'][2]; $watch = 'Propel Query ' . (count($this->queries) + 1); if ('PropelPDO::prepare' === $method) { $this->isPrepared = true; $this->stopwatch->start($watch, 'propel'); $add = false; } elseif ($this->isPrepared) { $this->isPrepared = false; $this->stopwatch->stop($watch); } } if ($add) { $this->queries[] = $message; if (null !== $this->logger) { $this->logger->debug($message); } } }