Fixed the lap method. Added upgrade notes. Some CS fixes
This commit is contained in:
parent
7ed728a894
commit
bdf0334434
@ -10,6 +10,8 @@
|
|||||||
`MongoDate` instead of `MongoTimestamp`, which also makes it possible to use
|
`MongoDate` instead of `MongoTimestamp`, which also makes it possible to use
|
||||||
TTL collections in MongoDB 2.2+ instead of relying on the `gc()` method.
|
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
|
#### Deprecations
|
||||||
|
|
||||||
* The `Request::splitHttpAcceptHeader()` is deprecated and will be removed in 2.3.
|
* The `Request::splitHttpAcceptHeader()` is deprecated and will be removed in 2.3.
|
||||||
|
@ -18,7 +18,14 @@ namespace Symfony\Component\Stopwatch;
|
|||||||
*/
|
*/
|
||||||
class Stopwatch
|
class Stopwatch
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var Section[]
|
||||||
|
*/
|
||||||
private $sections;
|
private $sections;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
private $activeSections;
|
private $activeSections;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
@ -54,6 +61,8 @@ class Stopwatch
|
|||||||
* @see getSectionEvents
|
* @see getSectionEvents
|
||||||
*
|
*
|
||||||
* @param string $id The identifier of the section
|
* @param string $id The identifier of the section
|
||||||
|
*
|
||||||
|
* @throws \LogicException When there's no started section to be stopped
|
||||||
*/
|
*/
|
||||||
public function stopSection($id)
|
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
|
class Section
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var StopwatchEvent[]
|
||||||
|
*/
|
||||||
private $events = array();
|
private $events = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var null|float
|
||||||
|
*/
|
||||||
private $origin;
|
private $origin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Section[]
|
||||||
|
*/
|
||||||
private $children = array();
|
private $children = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -236,7 +266,7 @@ class Section
|
|||||||
*/
|
*/
|
||||||
public function lap($name)
|
public function lap($name)
|
||||||
{
|
{
|
||||||
return $this->stop($name)->start();
|
return $this->stopEvent($name)->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -249,3 +279,4 @@ class Section
|
|||||||
return $this->events;
|
return $this->events;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,9 +18,24 @@ namespace Symfony\Component\Stopwatch;
|
|||||||
*/
|
*/
|
||||||
class StopwatchEvent
|
class StopwatchEvent
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var StopwatchPeriod[]
|
||||||
|
*/
|
||||||
private $periods;
|
private $periods;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var float
|
||||||
|
*/
|
||||||
private $origin;
|
private $origin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
private $category;
|
private $category;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var float[]
|
||||||
|
*/
|
||||||
private $started;
|
private $started;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,6 +89,8 @@ class StopwatchEvent
|
|||||||
/**
|
/**
|
||||||
* Stops the last started event period.
|
* Stops the last started event period.
|
||||||
*
|
*
|
||||||
|
* @throws \LogicException When start wasn't called before stopping
|
||||||
|
*
|
||||||
* @return StopwatchEvent The event
|
* @return StopwatchEvent The event
|
||||||
*/
|
*/
|
||||||
public function stop()
|
public function stop()
|
||||||
@ -182,7 +199,7 @@ class StopwatchEvent
|
|||||||
/**
|
/**
|
||||||
* Formats a time.
|
* Formats a time.
|
||||||
*
|
*
|
||||||
* @param numerical $time A raw time
|
* @param integer|float $time A raw time
|
||||||
*
|
*
|
||||||
* @return float The formatted time
|
* @return float The formatted time
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user