One problem with that is it doesn't really tell you how much of that time is spent in your program and how much is spent by your program waiting (for a database, or the network, or a disk drive, or another program getting a time slice, etc.). There's not much point in trying to speed up a piece of code that does nothing but wait for something out of your control.
If you still like that style of timing anyway, you could get better results with Time::HiRes.
| [reply] |
Apples and oranges. Profiling is not about timing; profiling tells you 'where' your code spends it's time. Where your code 'is' useful is timing long runs of linear code whereas the Benchmark module is useful for snippets of code and getting at the internals of subroutines without measuring the subroutine call itself. As to just storing time(), actually I've done that myself on occasion but usually I use the Time::HiRes module.
s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s
|-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,,
$|=1,select$,,$,,$,,1e-1;print;redo}
| [reply] [d/l] |