/** * Creates a profile point with the specified starting time and memory. * * This method will only add a point if no other points have been added as the ProfilePointInterface objects created before changing * the start point would result in inaccurate measurements. * * @param float $timeStamp Unix timestamp in microseconds when the profiler should start measuring time. * @param integer $memoryBytes Memory amount in bytes when the profiler should start measuring memory. * * @return ProfilerInterface This method is chainable. * * @since 1.2.0 * @throws \RuntimeException */ public function setStart($timeStamp = 0.0, $memoryBytes = 0) { if (!empty($this->points)) { throw new \RuntimeException('The start point cannot be adjusted after points are added to the profiler.'); } $this->startTimeStamp = $timeStamp; $this->startMemoryBytes = $memoryBytes; $point = new ProfilePoint('start'); // Store the point. $this->points[] = $point; // Add it in the lookup table. $this->lookup[$point->getName()] = count($this->points) - 1; return $this; }
/** * Tests the getMemoryMegaBytes method. * * @return void * * @covers \Joomla\Profiler\ProfilePoint::getMemoryMegaBytes * @since 1.0 */ public function testGetMemoryMegaBytes() { $profilePoint = new ProfilePoint('test', 0, 0); $this->assertEquals($profilePoint->getMemoryMegaBytes(), 0); $profilePoint = new ProfilePoint('test', 0, 1048576); $this->assertEquals($profilePoint->getMemoryMegaBytes(), 1); }
/** * @covers \Joomla\Profiler\ProfilePoint::getMemoryMegaBytes */ public function testThePointMemoryIsReturnedInMegabytes() { $profilePoint = new ProfilePoint('test', 0, 1048576); $this->assertEquals($profilePoint->getMemoryMegaBytes(), 1); }