I just tried it, for me the first one was consistently slower by around 0.0005 seconds over 10,000 iterations. You can use this bit of code to quickly benchmark code, run the script a few times to get a consistent time.
$i = 0;
// Change 10000 to the number of times to run the code. The larger the function the less you will likely want to run it.
while ($i != 10000)
{
// Code you want to benchmark goes here.
echo "</p>\n";
I just tried it, for me the first one was consistently slower by around 0.0005 seconds over 10,000 iterations. You can use this bit of code to quickly benchmark code, run the script a few times to get a consistent time....
Is that 0.0005 seconds per iteration, or per the full 10,000 iterations. If the latter, it's not even worth a second of your time to worry about. If the former (.0005sec/instance) it's still really not worth worrying about unless you're programming some large, intense, high-demand application where every microsecond matters.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Is that 0.0005 seconds per iteration, or per the full 10,000 iterations. If the latter, it's not even worth a second of your time to worry about. If the former (.0005sec/instance) it's still really not worth worrying about unless you're programming some large, intense, high-demand application where every microsecond matters.
In PHP??!?
Originally Posted by temp.user123
You know... You're not so smart. Do you need me to educate you?
If you say, "please," (and do so, nicely) then I will show you where you're dead wrong.
Exactly. When microseconds become important, it's probably time to to brush up on your Assembler skills.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
You know... You're not so smart. Do you need me to educate you?
If you say, "please," (and do so, nicely) then I will show you where you're dead wrong.
Bookmarks