On Dec 21, 2007 3:49 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> I want to determine the duration of the single iterations of
> a for-loop i.e. after each iteration the duration should
> be printed out. Is there a function for this implemented or
> must this be done with the difference of two times
> derived from localtime? Thank you very much!

Why do you want this? Are you trying to measure real-world seconds, or
CPU seconds, or something else? Would mere one second resolution be
sufficient, or would it be better to track milliseconds or something
even smaller? Do you intend to include the I/O overhead of printing
out a string during each iteration? Do you want to try to determine
whether some iterations run faster than others? Do you want to profile
your code to find what's taking long to run? Do you want to determine
how rapidly your code can respond to some event? Do you want to
measure I/O and system delays as well as data processing time? Do you
want to print out a few numbers that you can show to your friends and
brag about how rapidly your algorithm runs? In short, what are you
really trying to do? I'm not trying to be nosy. If you tell us what
you're trying to accomplish, we can give you better advice than if we
guess about what you're doing.

Having said that, here's my guess at a good answer for you. A fairly
easy and straightforward way to measure time intervals with resolution
better than one second would be with the help of a module like this
one:

    http://search.cpan.org/~kitdekat/Perf-Stopwatch-0.10.2/

This assumes that your system supports the underlying Time::HiRes
module. If it doesn't, what I think you're asking for may not be
possible on your system.

Good luck with it!

--Tom Phoenix
Stonehenge Perl Training

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to