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
float 3.8314838409424 | |
float 2.6161198616028 |
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 Field { | |
protected $a = 'a'; | |
protected $b = 'b'; | |
protected $c = 'c'; | |
protected static $options = array('a', 'b'); | |
public static function getOptions() { | |
return static::$options; | |
} | |
public static $options2 = array('a', 'b'); | |
} | |
class SubField extends Field { | |
protected static $options = array('c'); | |
public static $options2 = array('c'); | |
} | |
class SubField2 extends Field { | |
} | |
$instance = new SubField2; | |
$start = microtime(true); | |
for ($i = 0; $i < 100000; $i++) { | |
Field::getOptions(); | |
SubField::getOptions(); | |
SubField2::getOptions(); | |
foreach (SubField2::getOptions() as $option) { | |
$reflProperty = new ReflectionProperty('SubField2', $option); | |
$reflProperty->setAccessible(true); | |
$reflProperty->getValue($instance); | |
} | |
} | |
var_dump(microtime(true) - $start); | |
$start = microtime(true); | |
for ($i = 0; $i < 100000; $i++) { | |
if (isset(Field::$options2)) { | |
Field::$options2; | |
} | |
if (isset(SubField::$options2)) { | |
SubField::$options2; | |
} | |
if (isset(SubField2::$options2)) { | |
SubField2::$options2; | |
} | |
foreach (SubField2::$options2 as $option) { | |
$reflProperty = new ReflectionProperty('SubField2', $option); | |
$reflProperty->setAccessible(true); | |
$reflProperty->getValue($instance); | |
} | |
} | |
var_dump(microtime(true) - $start); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment