The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.


Time::Stats - Easy timing info


use Time::Stats;




# If you don't want to import the above methods:

use Time::Stats ();

Time::Stats::clear(); Time::Stats::mark(); Time::Stats::stats();


This module is designed to make it very easy to get timing info for your code, ala Time::HiRes, without needing to remember tv_interval and [gettimeofday], or writing your own methods for processing data. This is mainly useful if DProf doesn't give you useful info on what's slowing you down, and you need to inspect larger sections of code.

It's pretty smart about loops and being used in persistent environments such as mod_perl.

mark( [$name] )

Flags a point in the code to pay attention to. Times will be reported for the code in between two calls to mark within the same file. If the calls to mark are inside of a loop, the times between two calls to mark will be summed.

Takes an optional scalar mark name which will label the time that this mark completes in the output generated by stats(). If no name is passed, output will be labeled by line number.


Removes all data currently tracked, in all files.


Prints a synopsis to STDERR. This displays time per file, with the slowest intervals sorted to the top of each file.


Patrick A. Michaud, <>


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