Last active
December 10, 2015 07:09
-
-
Save bayleedev/4399208 to your computer and use it in GitHub Desktop.
Test2.php: 8.0589056015015
Test1.php: 8.0747842788696
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 | |
// Create array | |
$items = range(0,100000); | |
$times = array(); | |
$realArray = array(); // id and name | |
$metaArray = array(); // token and bob | |
foreach ($items as &$item) { | |
$realArray[] = array( | |
'id' => $item['id'], | |
'name' => $item['name'], | |
); | |
$metaArray[] = array( | |
'token' => $item['token'], | |
'bob' => $item['bob'], | |
); | |
} | |
$times[0] = microtime(true); | |
foreach ($realArray as $item) { | |
if ($item['id'] === 30) { | |
false; | |
} | |
} | |
$times[1] = microtime(true); | |
echo ($times[1] - $times[0]) * 100; |
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 | |
// Create array | |
$items = range(0,100000); | |
$times = array(); | |
$bigArray = array(); // all data is stored | |
foreach ($items as &$item) { | |
$bigArray[] = array( | |
'id' => $item['id'], | |
'name' => $item['name'], | |
'token' => $item['token'], | |
'bob' => $item['bob'], | |
); | |
} | |
$times[0] = microtime(true); | |
foreach ($bigArray as $item) { | |
if ($item['id'] === 30) { | |
false; | |
} | |
} | |
$times[1] = microtime(true); | |
echo ($times[1] - $times[0]) * 100; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment