tomcatexodus
Aug 25th, 2010, 01:34 AM
For discussion;
I've read up on (and performed my own) benchmarking for lengthy tasks and their faster functional equivalencies in PHP. Often it's said that micro-optimizing code is a worthless task, but I figure; sort them out before deployment to minimize code maintenance if the project grows.
A common one is foreach vs. various. foreach often fails in efficiency. Now, in my tests (and I've not seen this method much) when you want to iterate straight through an array, the following works the fastest:
$i_ceil = count($my_array);
while($i++ <= $i_ceil){
//process on $my_array[$i]
}
Has anyone encountered faster? Has anyone found this approach unfeasible?
I've read up on (and performed my own) benchmarking for lengthy tasks and their faster functional equivalencies in PHP. Often it's said that micro-optimizing code is a worthless task, but I figure; sort them out before deployment to minimize code maintenance if the project grows.
A common one is foreach vs. various. foreach often fails in efficiency. Now, in my tests (and I've not seen this method much) when you want to iterate straight through an array, the following works the fastest:
$i_ceil = count($my_array);
while($i++ <= $i_ceil){
//process on $my_array[$i]
}
Has anyone encountered faster? Has anyone found this approach unfeasible?