Exemple #1
0
 public function testGetAverageTime()
 {
     $result = new \r8\Benchmark\Result("test");
     $this->assertSame(0, $result->getAverageTime());
     $result->addTime(0.5);
     $result->addTime(0.05);
     $result->addTime(0.001);
     $result->addTime(0.05);
     $this->assertSame("0.15025", (string) $result->getAverageTime());
 }
Exemple #2
0
 /**
  * Runs the test and returns the result
  *
  * @param Integer $times The number of times to run this test
  * @return \r8\Benchmark\Result
  */
 public function run($times = 1000)
 {
     $result = new \r8\Benchmark\Result($this->name);
     $times = max((int) $times, 1);
     $test = $this->test;
     for ($i = 0; $i < $times; $i++) {
         $start = microtime(TRUE);
         $test();
         $end = microtime(TRUE);
         $result->addTime($end - $start);
     }
     return $result;
 }