|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-02-01 05:30 UTC] aharvey@php.net
-Status: Open
+Status: Bogus
[2011-02-01 05:30 UTC] aharvey@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 21:00:01 2025 UTC |
Description: ------------ When array data is int value, array_intersect() speed VERY SLOW. Test script: --------------- <?php ini_set('memory_limit', -1); $data_a = rand_data(FALSE); $data_b = rand_data(FALSE); $time = microtime(TRUE); $result = array_intersect($data_a, $data_b); $time = microtime(TRUE) - $time; echo " -> array_intersect by intval: {$time}, result: " . count($result) . "\r\n"; $data_a = rand_data(TRUE); $data_b = rand_data(TRUE); $time = microtime(TRUE); $result = array_intersect($data_a, $data_b); $time = microtime(TRUE) - $time; echo " -> array_intersect by string: {$time}, result: " . count($result) . "\r\n"; function rand_data($need_string) { mt_srand(); $result = array(); for ($i = 0; $i < 300000; $i++) { if ($need_string === TRUE) { $result[] = (string)mt_rand(); } else { $result[] = mt_rand(); } } return $result; } ?> Expected result: ---------------- almost same? Actual result: -------------- -> array_intersect by intval: 10.661009073257, result: 47 -> array_intersect by string: 1.3067090511322, result: 41