line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tool::Bench::Report::JSON; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Tool::Bench::Report::JSON::VERSION = '0.003'; |
4
|
|
|
|
|
|
|
} |
5
|
1
|
|
|
1
|
|
7
|
use Mouse; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
11
|
|
6
|
1
|
|
|
1
|
|
517
|
use JSON; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
7
|
1
|
|
|
1
|
|
297
|
use List::Util qw{min max sum }; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
112
|
|
8
|
1
|
|
|
1
|
|
5
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
244
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 JSON |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Builds a json report as follows (though it does not format this nicely): |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head2 report |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
[ |
17
|
|
|
|
|
|
|
{ |
18
|
|
|
|
|
|
|
'max_time' => '3.50475311279297e-05', |
19
|
|
|
|
|
|
|
'total_runs' => 4, |
20
|
|
|
|
|
|
|
'min_time' => '2.09808349609375e-05', |
21
|
|
|
|
|
|
|
'avg_time' => '2.55107879638672e-05', |
22
|
|
|
|
|
|
|
'name' => 'true', |
23
|
|
|
|
|
|
|
'total_time' => '0.000102043151855469', |
24
|
|
|
|
|
|
|
'times' => [ |
25
|
|
|
|
|
|
|
'2.40802764892578e-05', |
26
|
|
|
|
|
|
|
'2.09808349609375e-05', |
27
|
|
|
|
|
|
|
'3.50475311279297e-05', |
28
|
|
|
|
|
|
|
'2.19345092773438e-05' |
29
|
|
|
|
|
|
|
] |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
] |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub report { |
36
|
1
|
|
|
1
|
1
|
55
|
my ($self,%args) = @_; |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
3
|
my @report_items = qw{ min_time max_time total_time avg_time total_runs name note times }; #this is kinda janky |
39
|
|
|
|
|
|
|
|
40
|
4
|
|
|
|
|
7
|
encode_json( [ map { my $item = $_; |
|
5
|
|
|
|
|
19
|
|
41
|
32
|
|
|
|
|
202
|
my $x = |
42
|
|
|
|
|
|
|
{ ( |
43
|
|
|
|
|
|
|
interp => $args{interp}, |
44
|
4
|
|
|
|
|
7
|
map { $_ => $item->$_ } @report_items, |
45
|
|
|
|
|
|
|
) |
46
|
|
|
|
|
|
|
} |
47
|
1
|
|
|
|
|
2
|
} sort {$a->total_time <=> $b->total_time} @{$args{items}}, |
|
1
|
|
|
|
|
6
|
|
48
|
|
|
|
|
|
|
]); |
49
|
|
|
|
|
|
|
}; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|