mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-27 05:26:41 +00:00
Add start/end time accessors on Profile
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# 3.15.0 (2024-XX-XX)
|
||||
|
||||
* Add `Profile::getStartTime()` and `Profile::getEndTime()`
|
||||
* Fix "ignore missing" when used on an "embed" tag
|
||||
* Fix the possibility to override an aliased block (via use)
|
||||
* Add template cache hot reload
|
||||
|
||||
@@ -99,6 +99,22 @@ final class Profile implements \IteratorAggregate, \Serializable
|
||||
return isset($this->ends['wt']) && isset($this->starts['wt']) ? $this->ends['wt'] - $this->starts['wt'] : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the start time in microseconds.
|
||||
*/
|
||||
public function getStartTime(): float
|
||||
{
|
||||
return $this->starts['wt'] ?? 0.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the end time in microseconds.
|
||||
*/
|
||||
public function getEndTime(): float
|
||||
{
|
||||
return $this->ends['wt'] ?? 0.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the memory usage in bytes.
|
||||
*/
|
||||
|
||||
@@ -80,6 +80,15 @@ class ProfileTest extends TestCase
|
||||
$this->assertTrue($profile->getDuration() > 0, \sprintf('Expected duration > 0, got: %f', $profile->getDuration()));
|
||||
}
|
||||
|
||||
public function testTimeAccessors()
|
||||
{
|
||||
$current = microtime(true);
|
||||
$profile = new Profile();
|
||||
|
||||
$this->assertEqualsWithDelta($current, $profile->getStartTime(), 1);
|
||||
$this->assertSame(0.0, $profile->getEndTime());
|
||||
}
|
||||
|
||||
public function testSerialize()
|
||||
{
|
||||
$profile = new Profile('template', 'type', 'name');
|
||||
|
||||
Reference in New Issue
Block a user