Created
July 1, 2009 10:54
-
-
Save oelmekki/138722 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 | |
class Foo | |
{ | |
public function __construct() | |
{ | |
sleep( 1 ); | |
} | |
} | |
/** | |
* With new | |
*/ | |
$collec = array(); | |
$first_start = time(); | |
for ( $i = 0; $i < 10; $i++ ) | |
{ | |
$collec[] = new Foo(); | |
} | |
$first_stop = time(); | |
echo $first_stop - $first_start . "\n"; | |
/** | |
* With clone | |
*/ | |
$collec = array(); | |
$second_start = time(); | |
$carbon = new Foo(); | |
for ( $i = 0; $i < 10; $i++ ) | |
{ | |
$collec[] = clone $carbon; | |
} | |
$second_stop = time(); | |
echo $second_stop - $second_start . "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment