Permalink
Browse files

final

  • Loading branch information...
1 parent ce20475 commit d912f5c6dc465413ea6d1d113ee2b96e74999fa0 @cordoval committed Nov 11, 2012
Showing with 17 additions and 19 deletions.
  1. +17 −19 test.php
View
@@ -6,22 +6,20 @@
$examples = new Examples();
-$start = microtime(true);
-$examples->nastyExample();
-echo 'nasty ........ ' . (microtime(true) - $start) . "\n";
-
-$start = microtime(true);
-$examples->goodExample();
-echo 'good ........ ' . (microtime(true) - $start) . "\n";
-
-$start = microtime(true);
-$examples->goodAndFastExample();
-echo 'good and fast ... ' . (microtime(true) - $start) . "\n";
-
-$start = microtime(true);
-$examples->goodAndFastAndAutomaticExample();
-echo 'good and fast and automatic ' . (microtime(true) - $start) . "\n";
-
-$start = microtime(true);
-$examples->pimpleRefactorExample();
-echo 'pimple refactor ' . (microtime(true) - $start) . "\n";
+$exampleNames = array(
+ 'nastyExample',
+ 'goodExample',
+ 'goodAndFastExample',
+ 'goodAndFastAndAutomaticExample',
+ 'pimpleRefactorExample'
+);
+
+timeExample($exampleNames, $examples);
+
+function timeExample($methodNames, $examples) {
+ foreach ($methodNames as $methodName) {
+ $start = microtime(true);
+ call_user_func(array($examples, $methodName));
+ echo $methodName . '........ ' . (microtime(true) - $start) . "\n";
+ }
+}

0 comments on commit d912f5c

Please sign in to comment.