Ejemplo n.º 1
0
 /**
  * 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);
 }
Ejemplo n.º 2
0
 /**
  * @param PerformanceInfoInterface $performanceInfo
  * @return string
  */
 private function informAboutPeakingMemoryAllocation(PerformanceInfoInterface $performanceInfo)
 {
     $peakMemAllocation = $performanceInfo->peakMemoryAllocated();
     if ($peakMemAllocation / $performanceInfo->memoryAllocated() > 1.00001 && $this->highestMemoryPeak == $peakMemAllocation) {
         // We found peak mem allocation in a snapshot
         $message = 'Memory consumption peaked at &quot;' . $this->nameOfSnapShotThatHasMemoryPeak . '&quot; with a total allocation of <strong>' . $peakMemAllocation . '</strong> mb';
     } else {
         $message = 'Peak memory allocation was <strong>' . $peakMemAllocation . '</strong> mb';
     }
     return '<div class="footer"><em>' . $message . '</em></div>';
 }