(minor) add quick and dirty timer code to Common.pm

redis
Sitaram Chamarty 2012-11-09 17:54:04 +05:30
parent 8a9564f171
commit d491b5384f
1 changed files with 17 additions and 0 deletions

View File

@ -14,6 +14,8 @@ package Gitolite::Common;
gl_log
dd
t_start
t_lap
);
#>>>
use Exporter 'import';
@ -70,6 +72,21 @@ sub dd {
dbg(@_);
}
{
use Time::HiRes;
my %start_times;
sub t_start {
my $name = shift || 'default';
$start_times{$name} = [ Time::HiRes::gettimeofday() ];
}
sub t_lap {
my $name = shift || 'default';
return Time::HiRes::tv_interval( $start_times{$name} );
}
}
sub _warn {
gl_log( 'warn', @_ );
if ( $ENV{D} and $ENV{D} >= 3 ) {