Created
October 11, 2015 19:12
-
-
Save asgrim/6d15b30cbba2b8b6091d to your computer and use it in GitHub Desktop.
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 | |
require "vendor/autoload.php"; | |
class Foo { | |
public function bar() {} | |
} | |
$c = 1000; | |
echo "using method_exists... "; | |
$t = microtime(true); | |
for($i = 0; $i < $c; $i++) { | |
method_exists('Foo', 'bar'); | |
} | |
echo (microtime(true) - $t) . " seconds.\n"; | |
echo "using core reflection... "; | |
$t = microtime(true); | |
for($i = 0; $i < $c; $i++) { | |
$r = new ReflectionClass('Foo'); | |
$r->hasMethod('bar'); | |
} | |
echo (microtime(true) - $t) . " seconds.\n"; | |
echo "using better reflection... "; | |
$t = microtime(true); | |
for($i = 0; $i < $c; $i++) { | |
$br = \BetterReflection\Reflection\ReflectionClass::createFromName('Foo'); | |
$br->hasMethod('bar'); | |
} | |
echo (microtime(true) - $t) . " seconds.\n"; | |
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
using method_exists... 0.0006260871887207 seconds. | |
using core reflection... 0.0013439655303955 seconds. | |
using better reflection... 7.447105884552 seconds. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment