line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
626
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
57
|
|
3
|
|
|
|
|
|
|
package BenchmarkAnything::Config; |
4
|
|
|
|
|
|
|
BEGIN { |
5
|
1
|
|
|
1
|
|
274
|
$BenchmarkAnything::Config::AUTHORITY = 'cpan:SCHWIGON'; |
6
|
|
|
|
|
|
|
} |
7
|
|
|
|
|
|
|
# ABSTRACT: Read BenchmarkAnything configfile |
8
|
|
|
|
|
|
|
$BenchmarkAnything::Config::VERSION = '0.001'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new |
11
|
|
|
|
|
|
|
{ |
12
|
3
|
|
|
3
|
1
|
1746
|
my $class = shift; |
13
|
3
|
|
|
|
|
10
|
my $self = bless { @_ }, $class; |
14
|
3
|
|
|
|
|
11
|
$self->_read_config; |
15
|
3
|
|
|
|
|
11
|
return $self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _read_config |
20
|
|
|
|
|
|
|
{ |
21
|
3
|
|
|
3
|
|
6
|
my ($self) = @_; |
22
|
|
|
|
|
|
|
|
23
|
3
|
|
|
|
|
15317
|
require File::HomeDir; |
24
|
3
|
|
|
|
|
31446
|
require YAML::Any; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# don't look into user's homedir if we are running tests |
27
|
3
|
50
|
|
|
|
1038
|
my $default_cfgfile = $ENV{HARNESS_ACTIVE} ? "t/benchmarkanything.cfg" : File::HomeDir->my_home . "/.benchmarkanything/default.cfg"; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# read file |
30
|
3
|
|
|
|
|
7
|
eval { |
31
|
3
|
|
66
|
|
|
31
|
$self->{cfgfile} = $self->{cfgfile} || $ENV{BENCHMARKANYTHING_CONFIGFILE} || $default_cfgfile; |
32
|
3
|
|
|
|
|
5
|
my $cfg_yaml; |
33
|
3
|
50
|
|
|
|
136
|
open (my $CFG, "<", $self->{cfgfile}) or die "Can't read: ".$self->{cfgfile}."\n"; |
34
|
|
|
|
|
|
|
{ |
35
|
3
|
|
|
|
|
6
|
local $/; |
|
3
|
|
|
|
|
14
|
|
36
|
3
|
|
|
|
|
67
|
$cfg_yaml = <$CFG>; |
37
|
|
|
|
|
|
|
} |
38
|
3
|
|
|
|
|
11
|
my $config = YAML::Any::Load($cfg_yaml); |
39
|
3
|
|
|
|
|
35076
|
$self->{benchmarkanything} = $config->{benchmarkanything}; |
40
|
|
|
|
|
|
|
}; |
41
|
3
|
50
|
|
|
|
16
|
if ($@) |
42
|
|
|
|
|
|
|
{ |
43
|
0
|
|
|
|
|
0
|
die "benchmarkanything: error loading configfile: $@\n"; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# defaults |
47
|
3
|
|
50
|
|
|
23
|
$self->{benchmarkanything}{backend} ||= 'local'; |
48
|
|
|
|
|
|
|
|
49
|
3
|
|
|
|
|
8
|
return $self; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |