NAME

Time::Stopwatch - Use tied scalars as timers

SYNOPSIS

use Time::Stopwatch;
tie my $timer, 'Time::Stopwatch';

do_something();
print "Did something in $timer seconds.\n";

my @times = map {
    $timer = 0;
    do_something_else();
    $timer;
} 1 .. 5;

DESCRIPTION

The Time::Stopwatch module provides a convenient interface to timing functions through tied scalars. From the point of view of the user, scalars tied to the module simply increase their value by one every second.

Using the module should mostly be obvious from the synopsis. You can provide an initial value for the timers either by assigning to them or by passing the value as a third argument to tie().

If you have the module Time::HiRes installed, the timers created by Time::Stopwatch will automatically count fractional seconds. Do not assume that the values of the timers are always integers. You may test the constant Time::Stopwatch::HIRES to find out whether high resolution timing is enabled.

CHANGE LOG

0.03 (27 Feb 2001)

Modified tests to give more information, reduced subsecond accuracy test to 1/10 seconds to allow for inaccurate select() implementations. Tweaked synopsis and README.

SEE ALSO

Time::HiRes, tie()

AUTHORS

Copyright 2000-2001, Ilmari Karonen. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Address bug reports and comments to: perl@itz.pp.sci.fi