PHP Timing Issues
Posted: Tue Jul 02, 2002 12:48 pm
Okay, I was wondering about some things, and ran some tests, and I just wanted to verify my logic. The tests, with results, and the source code can be found here:
http://www.devnetwork.net/speedTest.php
I just need to verify my conclusions, which are:
1. array_flip()/isset() v.s. in_array()
array_flip()/isset() is faster than in_array() when the test result cannot be found, however, if the test result can be found, it can be much faster. However, this is only considering that the test result is close to the start of the array.
To search for an element at the beginning of the array:
http://www.devnetwork.net/speedTest.php?name=first
To search for an element in the middle of the array:
http://www.devnetwork.net/speedTest.php?name=middle
To search for an element at the end of the array:
http://www.devnetwork.net/speedTest.php?name=last
2. array_flip()/array_flip() v.s. array_unique()
Again, array_flip()/array_flip() twice on the same array is faster than array_unique(). This is an expected result.
Can anyone confirm the validity of these tests, and like I said, the logic?
http://www.devnetwork.net/speedTest.php
I just need to verify my conclusions, which are:
1. array_flip()/isset() v.s. in_array()
array_flip()/isset() is faster than in_array() when the test result cannot be found, however, if the test result can be found, it can be much faster. However, this is only considering that the test result is close to the start of the array.
To search for an element at the beginning of the array:
http://www.devnetwork.net/speedTest.php?name=first
To search for an element in the middle of the array:
http://www.devnetwork.net/speedTest.php?name=middle
To search for an element at the end of the array:
http://www.devnetwork.net/speedTest.php?name=last
2. array_flip()/array_flip() v.s. array_unique()
Again, array_flip()/array_flip() twice on the same array is faster than array_unique(). This is an expected result.
Can anyone confirm the validity of these tests, and like I said, the logic?