class Profile
Same name in this branch
- 11.1.x vendor/symfony/http-kernel/Profiler/Profile.php \Symfony\Component\HttpKernel\Profiler\Profile
@author Fabien Potencier <fabien@symfony.com>
Hierarchy
- class \Twig\Profiler\Profile implements \Twig\Profiler\IteratorAggregate, \Twig\Profiler\Serializable
Expanded class hierarchy of Profile
6 files declare their use of Profile
- BaseDumper.php in vendor/
twig/ twig/ src/ Profiler/ Dumper/ BaseDumper.php - BlackfireDumper.php in vendor/
twig/ twig/ src/ Profiler/ Dumper/ BlackfireDumper.php - HtmlDumper.php in vendor/
twig/ twig/ src/ Profiler/ Dumper/ HtmlDumper.php - ProfilerExtension.php in vendor/
twig/ twig/ src/ Extension/ ProfilerExtension.php - ProfilerNodeVisitor.php in vendor/
twig/ twig/ src/ Profiler/ NodeVisitor/ ProfilerNodeVisitor.php
26 string references to 'Profile'
- demo_umami.info.yml in core/
profiles/ demo_umami/ demo_umami.info.yml - core/profiles/demo_umami/demo_umami.info.yml
- DrupalAutoloader::register in vendor/
mglaman/ phpstan-drupal/ src/ Drupal/ DrupalAutoloader.php - DrupalKernel::getInstallProfile in core/
lib/ Drupal/ Core/ DrupalKernel.php - Gets the active install profile.
- DrupalKernel::moduleData in core/
lib/ Drupal/ Core/ DrupalKernel.php - Returns module data on the filesystem.
- drupal_install_system in core/
includes/ install.inc - Installs the system module.
File
-
vendor/
twig/ twig/ src/ Profiler/ Profile.php, line 17
Namespace
Twig\ProfilerView source
final class Profile implements \IteratorAggregate, \Serializable {
public const ROOT = 'ROOT';
public const BLOCK = 'block';
public const TEMPLATE = 'template';
public const MACRO = 'macro';
private $starts = [];
private $ends = [];
private $profiles = [];
public function __construct(string $template = 'main', string $type = self::ROOT, string $name = 'main') {
$this->name = str_starts_with($name, '__internal_') ? 'INTERNAL' : $name;
$this->enter();
}
public function getTemplate() : string {
return $this->template;
}
public function getType() : string {
return $this->type;
}
public function getName() : string {
return $this->name;
}
public function isRoot() : bool {
return self::ROOT === $this->type;
}
public function isTemplate() : bool {
return self::TEMPLATE === $this->type;
}
public function isBlock() : bool {
return self::BLOCK === $this->type;
}
public function isMacro() : bool {
return self::MACRO === $this->type;
}
/**
* @return Profile[]
*/
public function getProfiles() : array {
return $this->profiles;
}
public function addProfile(self $profile) : void {
$this->profiles[] = $profile;
}
/**
* Returns the duration in microseconds.
*/
public function getDuration() : float {
if ($this->isRoot() && $this->profiles) {
// for the root node with children, duration is the sum of all child durations
$duration = 0;
foreach ($this->profiles as $profile) {
$duration += $profile->getDuration();
}
return $duration;
}
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.
*/
public function getMemoryUsage() : int {
return isset($this->ends['mu']) && isset($this->starts['mu']) ? $this->ends['mu'] - $this->starts['mu'] : 0;
}
/**
* Returns the peak memory usage in bytes.
*/
public function getPeakMemoryUsage() : int {
return isset($this->ends['pmu']) && isset($this->starts['pmu']) ? $this->ends['pmu'] - $this->starts['pmu'] : 0;
}
/**
* Starts the profiling.
*/
public function enter() : void {
$this->starts = [
'wt' => microtime(true),
'mu' => memory_get_usage(),
'pmu' => memory_get_peak_usage(),
];
}
/**
* Stops the profiling.
*/
public function leave() : void {
$this->ends = [
'wt' => microtime(true),
'mu' => memory_get_usage(),
'pmu' => memory_get_peak_usage(),
];
}
public function reset() : void {
$this->starts = $this->ends = $this->profiles = [];
$this->enter();
}
public function getIterator() : \Traversable {
return new \ArrayIterator($this->profiles);
}
public function serialize() : string {
return serialize($this->__serialize());
}
public function unserialize($data) : void {
$this->__unserialize(unserialize($data));
}
/**
* @internal
*/
public function __serialize() : array {
return [
$this->template,
$this->name,
$this->type,
$this->starts,
$this->ends,
$this->profiles,
];
}
/**
* @internal
*/
public function __unserialize(array $data) : void {
[
$this->template,
$this->name,
$this->type,
$this->starts,
$this->ends,
$this->profiles,
] = $data;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
Profile::$ends | private | property | |
Profile::$profiles | private | property | |
Profile::$starts | private | property | |
Profile::addProfile | public | function | |
Profile::BLOCK | public | constant | |
Profile::enter | public | function | Starts the profiling. |
Profile::getDuration | public | function | Returns the duration in microseconds. |
Profile::getEndTime | public | function | Returns the end time in microseconds. |
Profile::getIterator | public | function | |
Profile::getMemoryUsage | public | function | Returns the memory usage in bytes. |
Profile::getName | public | function | |
Profile::getPeakMemoryUsage | public | function | Returns the peak memory usage in bytes. |
Profile::getProfiles | public | function | |
Profile::getStartTime | public | function | Returns the start time in microseconds. |
Profile::getTemplate | public | function | |
Profile::getType | public | function | |
Profile::isBlock | public | function | |
Profile::isMacro | public | function | |
Profile::isRoot | public | function | |
Profile::isTemplate | public | function | |
Profile::leave | public | function | Stops the profiling. |
Profile::MACRO | public | constant | |
Profile::reset | public | function | |
Profile::ROOT | public | constant | |
Profile::serialize | public | function | |
Profile::TEMPLATE | public | constant | |
Profile::unserialize | public | function | |
Profile::__construct | public | function | |
Profile::__serialize | public | function | @internal |
Profile::__unserialize | public | function | @internal |