Re: What is faster?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mark Cain wrote:
I checked the first expression with 1,000 iterations and it
took 0.00745 seconds.

Here is the code I used.

[snip]

$start1 = vsprintf('%d.%06d', gettimeofday());

Although many would argue that it's pointless to worry over such small details (and they have valid arguments), it's better to construct your benchmark so that the timing mechanism impacts your code as little as possible.

Although consistency is difficult to achieve without some effort, you can at least get your timing mechanism out of the code that you want to time. For example, using something like ab will let you test your code in its raw form - without the timing and looping.

I also dislike unit tests that are part of the code they're meant to test. :-)

Hope that helps.

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux