Fixed the lap method. Added upgrade notes. Some CS fixes

This commit is contained in:
Florin Patan 2012-11-09 22:03:11 +02:00
parent 7ed728a894
commit bdf0334434
3 changed files with 52 additions and 2 deletions

View File

@ -10,6 +10,8 @@
`MongoDate` instead of `MongoTimestamp`, which also makes it possible to use
TTL collections in MongoDB 2.2+ instead of relying on the `gc()` method.
* The Stopwatch functionality was moved from HttpKernel\Debug to its own component
#### Deprecations
* The `Request::splitHttpAcceptHeader()` is deprecated and will be removed in 2.3.

View File

@ -18,7 +18,14 @@ namespace Symfony\Component\Stopwatch;
*/
class Stopwatch
{
/**
* @var Section[]
*/
private $sections;
/**
* @var array
*/
private $activeSections;
public function __construct()
@ -54,6 +61,8 @@ class Stopwatch
* @see getSectionEvents
*
* @param string $id The identifier of the section
*
* @throws \LogicException When there's no started section to be stopped
*/
public function stopSection($id)
{
@ -117,11 +126,32 @@ class Stopwatch
}
}
/**
* @internal This class is for internal usage only
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class Section
{
/**
* @var StopwatchEvent[]
*/
private $events = array();
/**
* @var null|float
*/
private $origin;
/**
* @var string
*/
private $id;
/**
* @var Section[]
*/
private $children = array();
/**
@ -236,7 +266,7 @@ class Section
*/
public function lap($name)
{
return $this->stop($name)->start();
return $this->stopEvent($name)->start();
}
/**
@ -249,3 +279,4 @@ class Section
return $this->events;
}
}

View File

@ -18,9 +18,24 @@ namespace Symfony\Component\Stopwatch;
*/
class StopwatchEvent
{
/**
* @var StopwatchPeriod[]
*/
private $periods;
/**
* @var float
*/
private $origin;
/**
* @var string
*/
private $category;
/**
* @var float[]
*/
private $started;
/**
@ -74,6 +89,8 @@ class StopwatchEvent
/**
* Stops the last started event period.
*
* @throws \LogicException When start wasn't called before stopping
*
* @return StopwatchEvent The event
*/
public function stop()
@ -182,7 +199,7 @@ class StopwatchEvent
/**
* Formats a time.
*
* @param numerical $time A raw time
* @param integer|float $time A raw time
*
* @return float The formatted time
*