As a coder, I am trying to provide the fastest code I can. This is why I would like to benchmark my functions, though I know how results can be different from one computer to another.
However, what I see using PEAR::Benchmark is that the first function I benchmark is always slower than the next one, even if it is the same !
Here is a small example :
<?php
require_once 'Benchmark/Timer.php';
$timer = new Benchmark_Timer;
$timer->start();
10^9*10^9;
$timer->setMarker('Two');
10^9*10^6*10^3;
$timer->setMarker('Three');
10^9*10^9;
$timer->setMarker('Two2');
10^9*10^6*10^3;
$timer->setMarker('Three2');
10^9*10^9;
$timer->setMarker('Two3');
$timer->stop();
$timer->display();
?>
And here is the result :
Marker - ex time - %
Start - 0.00%
Two 0.000156 32.91%
Three 0.000064 13.50%
Two2 0.000064 13.50%
Three2 0.000063 13.29%
Two3 0.000063 13.29%
Stop 0.000064 13.50%
Two, Two2 and Two3 being, for instance, the exact same operation.
Is this normal ? If not, is my computer to blame (Win XP SP2 - PIII 733) ? Or PEAR::Benchmark ? Or me ? 🙂
Thanks in advance,
Frapfor