'; $output .= '

Bench run: '.date('d.m.Y H:i').'

'; foreach(get_class_methods(get_class($this)) as $method) { if (preg_match('#^bench.*#', $method)) { $ok = true; try { $result = $this->$method(); } catch (BenchmarkFailedException $tfex) { $result = $tfex->getMessage(); $ok = false; } } } $output .= ''; file_put_contents('result/benchmark.'.get_class($this).'.'.$this->getBenchmarkName().'.html', $output); } public final function doBenchmark() { $this->init(); try { $this->run(); } catch (Exception $ex) { echo $ex->getMessage(); echo '
';
			echo $ex->getTraceAsString();
			echo '
'; } $this->cleanup(); } } final class BenchmarkSuite { private $benchmarks = array(); private $name; public function __construct($name) { $this->name = $name; } public function addBenchmark(Benchmark $test) { $this->benchmarks[] = $test; } public function run() { $s = ''; foreach ($this->benchmarks as $test) { $s .= '
'; $s .= '

'.$test->getBenchmarkName().'

'; try { $test->doBenchmark(); $s .= '

Benchmark completed. Results

'; } catch (BenchmarkFailedException $tfex) { $s .= '

Benchmark failed: '.$tfex->getMessage().'

'; } foreach($test->getFails() as $fail) { $s .= "Benchmark: {$fail->test}
\n"; $s .= "Comment: {$fail->comment}
\n"; } } $s .= ''; file_put_contents('result/benchmarks.'.$this->name.'.html', $s); } }