Skip to content

Instantly share code, notes, and snippets.

@ronan-gloo
Last active December 17, 2015 22:49
Show Gist options
  • Select an option

  • Save ronan-gloo/5684470 to your computer and use it in GitHub Desktop.

Select an option

Save ronan-gloo/5684470 to your computer and use it in GitHub Desktop.
clone | new ArrayCollection
<?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