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

This commit is contained in:
Sitaram Chamarty 2012-11-09 17:54:04 +05:30
parent 8a9564f171
commit d491b5384f

View file

@ -14,6 +14,8 @@ package Gitolite::Common;
gl_log gl_log
dd dd
t_start
t_lap
); );
#>>> #>>>
use Exporter 'import'; use Exporter 'import';
@ -70,6 +72,21 @@ sub dd {
dbg(@_); 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 { sub _warn {
gl_log( 'warn', @_ ); gl_log( 'warn', @_ );
if ( $ENV{D} and $ENV{D} >= 3 ) { if ( $ENV{D} and $ENV{D} >= 3 ) {