Mark Cain wrote:
I see your point about including the timing code in the calculation itself
and while it does add time to the process, he is not just timing this
code -- he is timing this code against another. Meaning we don't want to
know "How fast is this code?" per se -- we want to know "Which is faster?"
So, arguably from the faster point of view, as long as the time mech is in
both tests, the question will be answered with a degree of certainty. From
the days of my boyhood, even if the race route were "two times around the
big oak tree," the faster runner would still win the race.
Question for you, please:
In your post you say:
time. For example, using something like ab will let you test your code
in its raw form - without the timing and looping.
What is ab? I am somewhat limited in my depth and scope of php and so I
have never seen this before. Care to point me in a direction where I could
learn more?
apache benchmark, try:
> man ab
on your local linux cmd line (assuming you have apache installed)
Mark Cain
----- Original Message -----
From: "Chris Shiflett" <shiflett@xxxxxxx>
To: "Mark Cain" <mark@xxxxxxxxxxxx>
Cc: "Andy Pieters" <mailings@xxxxxxxxxxxxxxxx>; <php-general@xxxxxxxxxxxxx>
Sent: Sunday, June 05, 2005 9:56 PM
Subject: Re: What is faster?
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