|
Posted by Chris Shiflett on 06/06/05 04:56
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/
Navigation:
[Reply to this message]
|