mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-17 04:46:49 +00:00
Add start/end time accessors on Profile
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
# 3.15.0 (2024-XX-XX)
|
# 3.15.0 (2024-XX-XX)
|
||||||
|
|
||||||
|
* Add `Profile::getStartTime()` and `Profile::getEndTime()`
|
||||||
* Fix "ignore missing" when used on an "embed" tag
|
* Fix "ignore missing" when used on an "embed" tag
|
||||||
* Fix the possibility to override an aliased block (via use)
|
* Fix the possibility to override an aliased block (via use)
|
||||||
* Add template cache hot reload
|
* 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;
|
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.
|
* 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()));
|
$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()
|
public function testSerialize()
|
||||||
{
|
{
|
||||||
$profile = new Profile('template', 'type', 'name');
|
$profile = new Profile('template', 'type', 'name');
|
||||||
|
|||||||
Reference in New Issue
Block a user