1: <?php
2:
3: namespace Demo;
4:
5: class Benchmark
6: {
7: private $durations;
8:
9: public function benchmark($name, $function)
10: {
11: $start = microtime(true);
12: $function();
13: $end = microtime(true);
14: $this->durations[$name] = $end - $start;
15: }
16:
17: public function getTime($name)
18: {
19: return $this->durations[$name];
20: }
21: }
22: