Last active
December 17, 2015 22:49
-
-
Save ronan-gloo/5684470 to your computer and use it in GitHub Desktop.
clone | new ArrayCollection
This file contains hidden or 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 | |
| $clone = new ArrayCollection; | |
| $steps = 10000; | |
| $instances = []; | |
| $start['new'] = microtime(true); | |
| foreach (range(1, $steps) as $k) { | |
| $instances[] = new ArrayCollection; | |
| } | |
| $end['new'] =microtime(true); | |
| $instances = []; | |
| $start['clone'] = microtime(true); | |
| foreach (range(1, $steps) as $k) { | |
| $instances[] = clone $clone; | |
| } | |
| $end['clone'] = microtime(true); | |
| echo 'With instances: '. round($end['new'] - $start['new'], 5)."\n"; | |
| echo 'With clones: '. round($end['clone'] - $start['clone'], 5)."\n"; | |
| // Résultats sur ma bécane: | |
| With instances: 0.04729 | |
| With clones: 0.01232 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment