/** * PerformanceInfo constructor. * @param float $created * @param float $timePassed * @param int $numClassesTotal * @param int $numFilesIncluded * @param float $memoryAllocated */ public function __construct($created, $timePassed, $numClassesTotal, $numFilesIncluded, $memoryAllocated) { $this->created = $created; $this->timePassed = $timePassed; $this->numClassesDeclared = $numClassesTotal; $this->numFilesIncluded = $numFilesIncluded; $this->memoryAllocated = $memoryAllocated; $this->peakMemoryAllocation = Utils::toMegaBytes(memory_get_peak_usage()); }
/** * PerformanceSnapshot constructor. * @param PerformanceInfoInterface|null $prev */ public function __construct(PerformanceInfoInterface $prev = null) { $timePassed = 0; $creationTime = Utils::getMicroTime(); if ($prev instanceof PerformanceInfoInterface) { $timePassed = bcsub($creationTime, $prev->creationTime(), 4); } else { $prev = new NullPerformanceInfoObject(); } $numClassesDeclared = count(get_declared_classes()); $numFilesIncluded = count(get_included_files()); $this->numClassesDeclaredSincePreviousSnapShot = $numClassesDeclared - $prev->numClassesDeclared(); $this->numFilesIncludedSincePreviousSnapShot = $numFilesIncluded - $prev->numFilesIncluded(); $memoryAllocated = Utils::toMegaBytes(memory_get_usage()); $this->memoryAllocatedDiff = bcsub($memoryAllocated, $prev->memoryAllocated(), 4); parent::__construct($creationTime, $timePassed, $numClassesDeclared, $numFilesIncluded, $memoryAllocated); }