
Hi Dne Tue, 07 Jun 2011 12:22:02 -0400 Marc Delisle <marc@infomarc.info> napsal(a):
I tested on a 64-bit Linux machine (running as a VM under ESX 4.1) under PHP 5.3.6-RC3 and got different results (for current master):
Binary search: 0.6088 array_search: 2.0246 isset: 0.0068 array_key_exists: 0.0176
I get similar numbers as well: Binary search: 0.6937 array_search: 3.393 isset: 0.0056 array_key_exists: 0.0228 What is also interesting is worst results achieved during search for all words in the array: Binary search: 1.3098 array_search: 4.0101 isset: 0.0333 array_key_exists: 0.0868 Both binary search and array_search give pretty inconsistent results. For the flipped array you expect to call array_flip or change data structure to already contain flipped array? I assume latter, because otherwise overhead for flipping array would probably make results worse. PS: in_array seems to perform slightly better than array_search. -- Michal Čihař | http://cihar.com | http://blog.cihar.com