note 10075 added to microtime
| From: | mcq at supergamez dot hu | Date: | Tue, 12 Dec 2000 03:47:37 +0000 |
| Subject: | note 10075 added to microtime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-8624@lists.php.net to get a copy of this message | ||
if you want to measure runtime of some code, and the result is really relevant, then keep in mind
the followings:
1. you should only measure the time the code runs. This means if you use functions to make a double
from microtime, then get begin time, run the code, get end time, and only _after_ this do conversion
and computing. This is relevant for short cycles.
2. if runtime is very small, you can put the code in a loop and run it for 100 or 1000 times. The
more you run it the more accurate the value will be. Do not forget to divide the runtime by the
times you ran it.
3. if you are measuring a loop, then you do not actually measure the runtime of one cycle. Some
caching may occur which means you will not get one cycle's runtime. For a short code, this can
eventually result in big differences. Use looping only if the code is long and comlicated.
4. your runtime will be highly affected by the load of the server, which may be effected by many
things - so, always run your runtime measuering multiple times, and, when comparing two methods, for
e.g., then measure their runtimes one after the other, so I mean do not use values from yesterday,
the circumstances may strongly affect your measuring.
Trapeer
http://www.php.net/manual/function.microtime.php