line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Profiler; |
6
|
|
|
|
|
|
|
|
7
|
102
|
|
|
102
|
|
1319
|
use v5.12.5; |
|
102
|
|
|
|
|
337
|
|
8
|
102
|
|
|
102
|
|
544
|
use warnings; |
|
102
|
|
|
|
|
191
|
|
|
102
|
|
|
|
|
5544
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.14.2.2'; # TRIAL VERSION |
11
|
|
|
|
|
|
|
|
12
|
102
|
|
|
102
|
|
36057
|
use Time::HiRes qw(gettimeofday tv_interval); |
|
102
|
|
|
|
|
129416
|
|
|
102
|
|
|
|
|
748
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
63
|
|
|
63
|
0
|
230
|
my $that = shift; |
16
|
63
|
|
33
|
|
|
822
|
my $proto = ref($that) || $that; |
17
|
63
|
|
|
|
|
223
|
my $self = {@_}; |
18
|
|
|
|
|
|
|
|
19
|
63
|
|
|
|
|
377
|
bless( $self, $proto ); |
20
|
|
|
|
|
|
|
|
21
|
63
|
|
|
|
|
783
|
$self->{__data} = {}; |
22
|
|
|
|
|
|
|
|
23
|
63
|
|
|
|
|
349
|
return $self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub start { |
27
|
1273
|
|
|
1273
|
0
|
4247
|
my ( $self, $info ) = @_; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
push( |
30
|
1273
|
|
|
|
|
2278
|
@{ $self->{__data}->{$info} }, |
|
1273
|
|
|
|
|
25438
|
|
31
|
|
|
|
|
|
|
{ |
32
|
|
|
|
|
|
|
start => [gettimeofday] |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub end { |
38
|
1273
|
|
|
1273
|
0
|
6212
|
my ( $self, $info ) = @_; |
39
|
|
|
|
|
|
|
|
40
|
1273
|
100
|
|
|
|
13019
|
return unless ( $self->{__data}->{$info}->[-1] ); |
41
|
|
|
|
|
|
|
|
42
|
121
|
|
|
|
|
639
|
my $data = $self->{__data}->{$info}->[-1]; |
43
|
121
|
|
|
|
|
1665
|
$data->{end} = [gettimeofday]; |
44
|
121
|
|
|
|
|
1905
|
$data->{duration} = tv_interval( $data->{start}, $data->{end} ); |
45
|
|
|
|
|
|
|
|
46
|
121
|
|
|
|
|
5190
|
$self->{__data}->{$info}->[-1] = $data; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub report { |
50
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
for my $info ( keys %{ $self->{__data} } ) { |
|
0
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
print "# $info (count: " . scalar( @{ $self->{__data}->{$info} } ) . ")\n"; |
|
0
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
print " Timings:\n"; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my ( $max, $min, $avg, $all ); |
57
|
0
|
|
|
|
|
|
for my $entry ( @{ $self->{__data}->{$info} } ) { |
|
0
|
|
|
|
|
|
|
58
|
0
|
0
|
0
|
|
|
|
if ( !$max || $max < $entry->{duration} ) { |
59
|
0
|
|
|
|
|
|
$max = $entry->{duration}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
0
|
|
|
|
if ( !$min || $min > $entry->{duration} ) { |
63
|
0
|
|
|
|
|
|
$min = $entry->{duration}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
$all += $entry->{duration}; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
$avg = $all / scalar( @{ $self->{__data}->{$info} } ); |
|
0
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
print " min: $min / max: $max / avg: $avg / all: $all\n"; |
72
|
0
|
|
|
|
|
|
print " Overview:\n"; |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
for my $entry ( @{ $self->{__data}->{$info} } ) { |
|
0
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
print " " . $entry->{duration} . "\n"; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
print |
79
|
0
|
|
|
|
|
|
"--------------------------------------------------------------------------------\n"; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |