Skip to content

Instantly share code, notes, and snippets.

@http-engine
Created October 15, 2009 08:26
Show Gist options
  • Save http-engine/210781 to your computer and use it in GitHub Desktop.
Save http-engine/210781 to your computer and use it in GitHub Desktop.
package Benchmark::Wrap;
use strict;
use warnings;
use Benchmark ();
BEGIN {
*_runloop = ¥&Benchmark::runloop;
}
our $BEFORE;
our $AFTER;
no warnings 'redefine';
sub Benchmark::runloop {
$BEFORE->() if ref($BEFORE) eq 'CODE';
my $ret = _runloop(@_);
$AFTER->() if ref($AFTER) eq 'CODE';
$ret;
}
'kazuho love';
__END__
use strict;
use warnings;
use Benchmark;
use Benchmark::Wrap;
$Benchmark::Wrap::BEFORE = sub { sleep 1 };
$Benchmark::Wrap::AFTER = sub { sleep 1 };
timethese(10, {
a => sub {},
b => sub {},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment