Last active
November 18, 2016 06:51
-
-
Save n0f/68b822dd8a953dd91a77240492729321 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 | |
$array1 = range(50000, 200000); | |
$array2 = range(0, 100000); | |
$array3 = range(150000, 250000); | |
shuffle($array1); | |
shuffle($array2); | |
shuffle($array3); | |
$timeStart = microtime(true); | |
array_diff($array1, $array2, $array3); | |
$timeFinish = microtime(true); | |
echo '処理時間: ' . ($timeFinish - $timeStart) . '秒' . PHP_EOL; |
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(50000, 200000); | |
$array2 = range(0, 100000); | |
$array3 = range(150000, 250000); | |
shuffle($array1); | |
shuffle($array2); | |
shuffle($array3); | |
$timeStart = microtime(true); | |
fast_array_diff($array1, $array2, $array3); | |
$timeFinish = microtime(true); | |
echo '処理時間: ' . ($timeFinish - $timeStart) . '秒' . PHP_EOL; | |
function fast_array_diff() | |
{ | |
return array_flip(call_user_func_array('array_diff_key', array_map('array_flip', func_get_args()))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment