line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
729
|
use 5.008; |
|
1
|
|
|
|
|
4
|
|
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
92
|
|
4
|
|
|
|
|
|
|
package BenchmarkAnything::Reporter; |
5
|
|
|
|
|
|
|
BEGIN { |
6
|
1
|
|
|
1
|
|
326
|
$BenchmarkAnything::Reporter::AUTHORITY = 'cpan:SCHWIGON'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
# ABSTRACT: Handle result reporting to a BenchmarkAnything HTTP/REST API |
9
|
|
|
|
|
|
|
$BenchmarkAnything::Reporter::VERSION = '0.001'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new |
12
|
|
|
|
|
|
|
{ |
13
|
2
|
|
|
2
|
1
|
1050
|
my $class = shift; |
14
|
2
|
|
|
|
|
6
|
my $self = bless { @_ }, $class; |
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
|
|
697
|
require BenchmarkAnything::Config; |
17
|
2
|
50
|
|
|
|
371
|
$self->{config} = BenchmarkAnything::Config->new unless $self->{config}; |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
|
|
36502
|
return $self; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub report |
24
|
|
|
|
|
|
|
{ |
25
|
0
|
|
|
0
|
1
|
|
my ($self, $data) = @_; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# --- validate --- |
28
|
0
|
0
|
|
|
|
|
if (not $data) |
29
|
|
|
|
|
|
|
{ |
30
|
0
|
|
|
|
|
|
die "benchmarkanything: no input data provided.\n"; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my $ua = $self->_get_user_agent; |
34
|
0
|
|
|
|
|
|
my $url = $self->_get_base_url."/api/v1/add"; |
35
|
0
|
0
|
0
|
|
|
|
print "Report data...\n" if $self->{verbose} or $self->{debug}; |
36
|
0
|
|
|
|
|
|
my $res = $ua->post($url => json => $data)->res; |
37
|
0
|
0
|
0
|
|
|
|
print "Done.\n" if $self->{verbose} or $self->{debug}; |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
die "benchmarkanything: ".$res->error->{message}." ($url)\n" if $res->error; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
return $self; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _get_user_agent |
45
|
|
|
|
|
|
|
{ |
46
|
0
|
|
|
0
|
|
|
require Mojo::UserAgent; |
47
|
0
|
|
|
|
|
|
return Mojo::UserAgent->new; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _get_base_url |
51
|
|
|
|
|
|
|
{ |
52
|
0
|
|
|
0
|
|
|
$_[0]->{config}{benchmarkanything}{backends}{http}{base_url}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
3 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |