function testCreationOfSnapShots() { $this->assertEmpty(self::$initSnap->timePassed()); $this->assertNotEmpty(self::$initSnap->numClassesDeclaredSincePreviousSnapshot()); $this->assertNotEmpty(self::$initSnap->numFilesIncludedSincePreviousSnapshot()); usleep(100); $snapShot = new PerformanceSnapshot(self::$initSnap); $this->assertNotEmpty($snapShot->timePassed()); $bytes = str_repeat('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 10000); $snapShot = new PerformanceSnapshot(self::$initSnap); $this->assertNotEmpty($snapShot->memoryAllocationDifference()); }
/** * @param \Closure $func * @param string $desc * @return TestRunResult */ private function runFunction($func, $desc) { $initSnapShot = new PerformanceSnapshot(); for ($i = $this->numRuns; $i > 0; $i--) { $func(); } $snapShot = new PerformanceSnapshot($initSnapShot); return new TestRunResult($desc, $snapShot->timePassed(), $snapShot->memoryAllocationDifference()); }