Created
October 31, 2018 01:31
-
-
Save 77web/2c535aa05568e792a5935b7e04751474 to your computer and use it in GitHub Desktop.
ネストforeachの配列ウチソト問題の計測用
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 | |
$array1 = range(1, 1000000); | |
$array2 = range(1, 10); | |
$start = microtime(true); | |
$result = []; | |
foreach ($array1 as $value1) { | |
foreach ($array2 as $value2) { | |
$result[] = $value1 * $value2; | |
} | |
} | |
$end = microtime(true); | |
var_dump(count($result)); | |
echo "duration:".($end - $start)."\n"; | |
echo "memory:".memory_get_peak_usage(true)."\n"; |
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 | |
$array2 = range(1, 1000000); | |
$array1 = range(1, 10); | |
$start = microtime(true); | |
$result = []; | |
foreach ($array1 as $value1) { | |
foreach ($array2 as $value2) { | |
$result[] = $value1 * $value2; | |
} | |
} | |
$end = microtime(true); | |
var_dump(count($result)); | |
echo "duration:".($end - $start)."\n"; | |
echo "memory:".memory_get_peak_usage(true)."\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment