http-engine (owner)

Revisions

gist: 210781 Download_button fork
public
Public Clone URL: git://gist.github.com/210781.git
Embed All Files: show embed
Perl #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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 {},
});