Created
November 9, 2017 02:15
-
-
Save floatflower/27a86a4c0fa7f2a33a25e8b3073fff03 to your computer and use it in GitHub Desktop.
FunctionDispatcher.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Dispatcher | |
{ | |
public function function1($a, $b) | |
{ | |
return $a + $b; | |
} | |
public function function2($a, $b) | |
{ | |
return $a * $b; | |
} | |
public function function3($a, $b) | |
{ | |
return $a / $b; | |
} | |
public function function4($a, $b) | |
{ | |
return ($a + 1) * ($b + 1); | |
} | |
public function function5($a, $b) | |
{ | |
return $a / $b; | |
} | |
public function function6($a, $b) | |
{ | |
return $a / $b; | |
} | |
public function function7($a, $b) | |
{ | |
return $a / $b; | |
} | |
public function function8($a, $b) | |
{ | |
return $a / $b; | |
} | |
public function function9($a, $b) | |
{ | |
return $a / $b; | |
} | |
public function function10($a, $b) | |
{ | |
return $a / $b; | |
} | |
} | |
$time1 = time(); | |
for ($i = 0; $i <= 10000000; $i ++) | |
{ | |
$function = new Dispatcher(); | |
$function->{"function1"}($i, $i + 1); | |
$function->{"function2"}($i, $i + 1); | |
$function->{"function3"}($i, $i + 1); | |
$function->{"function4"}($i, $i + 1); | |
$function->{"function5"}($i, $i + 1); | |
$function->{"function6"}($i, $i + 1); | |
$function->{"function7"}($i, $i + 1); | |
$function->{"function8"}($i, $i + 1); | |
$function->{"function9"}($i, $i + 1); | |
$function->{"function10"}($i, $i + 1); | |
} | |
$time2 = time(); | |
echo $time2 - $time1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment