A small improvement on getTimer. Using vsprintf instead of sprintf there is no need to assign the array:
<?php
function utime()
{
return (float) (vsprintf('%d.%06d', gettimeofday()));
}
?>
In a test on my machine getTimer took 0.037519 seconds to run through 1000 iterations versus 0.027912 seconds for utime. In total, utime runs about 25% quicker. The use is negligible in an actual benchmarking scenario, but this could provide a slightly more accurate estimate. Of course the time it takes to run the function could always be stored at the start and subtracted from your total value each time it is run.
gettimeofday
(PHP 4, PHP 5)
gettimeofday — Geef de huidige tijd
Beschrijving
array gettimeofday
( void
)
Dit is een interface naar gettimeofday(2). Het retourneert een associatieve array met de data die teruggegeven wordt van de system call.
- "sec" - seconden
- "usec" - microseconden
- "minuteswest" - minuten ten westen van Greenwich
- "dsttime" - type van dst correctie
gettimeofday
lucas dot karisny at linuxmail dot org
13-Feb-2005 06:26
13-Feb-2005 06:26
middleto at pilot dot msu dot edu
12-Aug-1999 07:49
12-Aug-1999 07:49
The types of DST correction (from sys/time.h on a Linux system):
0 Not on DST
1 USA DST
2 Austrailian DST
3 Western European DST
4 Middle European DST
5 Eastern European DST
6 Canada DST
7 Great Britain and Eire DST
8 Rumania DST
9 Turkey
10 Australian DST (with shift in 1986)
