blib/lib/Tapper/TestSuite/Benchmark/Perl/Formance.pm

filter: Statementstmt 15.2% 22 / 144 Branchbran 0.0% 0 / 32 Conditioncond 0.0% 0 / 10 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 25.9% 7 / 27 Podpod 100% 8 / 8 totaltotal 16.3% 37 / 226 CC 23 SCAR 25.6
CC
23
Cov
12%
get_options
42.0
send_report
30.0
tapper_section_meta
12.0
CRAP 12.9
↑ Summary
1 package Tapper::TestSuite::Benchmark::Perl::Formance;
2 # git description: v4.1.0-2-gd444784
3  
4 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 $Tapper::TestSuite::Benchmark::Perl::Formance::AUTHORITY = 'cpan:TAPPER';
6 }
7 {
8 1 $Tapper::TestSuite::Benchmark::Perl::Formance::VERSION = '4.1.1';
9 }
10 # ABSTRACT: Tapper - Wrapper for Benchmark::Perl::Formance
11  
12 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶use IO::Socket::INET;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Benchmark::Perl::Formance;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use Getopt::Long ":config", "no_ignore_case", "bundling";
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 0 ▶sub _uname {
Subroutine _uname: not called CC=1 SCAR=6.9
21 0 my $uname = `uname -a`;
22 0 chomp $uname;
23 0 return $uname;
24 }
25  
26 0 ▶sub _hostname {
Subroutine _hostname: not called CC=2 SCAR=17.9
27 0 my $hostname = `hostname`;
28 0 chomp $hostname;
29 0 ▶ $hostname = "perl64.org" if $hostname eq "h1891504"; # special case for PerlFormance.Net Æsthetics
Branch: 1 branch
BranchTrueFalseTotal
if $hostname eq "h1891504" 0 0 0
30 0 return $hostname;
31 }
32  
33 0 ▶sub _osname {
Subroutine _osname: not called CC=1 SCAR=6.9
34 0 my $osname = `cat /etc/issue.net | head -1`;
35 0 chomp $osname;
36 0 return $osname;
37 }
38  
39 0 ▶sub _cpuinfo {
Subroutine _cpuinfo: not called CC=2 SCAR=17.9
40 0 my @cpus = map { chomp; s/^\s*//; $_ } `grep 'model name' < /proc/cpuinfo | cut -d: -f2-`;
41 0 my %cpu_count = ();
42 0 $cpu_count{$_}++ foreach @cpus;
43  
44 0 my $cpuinfo = join(', ', map { $cpu_count{$_}." cores [$_]" } keys %cpu_count);
45 0 return $cpuinfo;
46 }
47  
48 0 ▶sub _ram {
Subroutine _ram: not called CC=1 SCAR=6.9
49 0 my $ram = `free -m | grep -i mem: | awk '{print \$2}'`;
50 0 chomp $ram;
51 0 $ram .= 'MB';
52 0 return $ram;
53 }
54  
55 0 ▶sub _starttime_test_program {
Subroutine _starttime_test_program: not called CC=1 SCAR=6.9
56 0 my $starttime_test_program = `date --rfc-2822` ;
57 0 chomp $starttime_test_program;
58 0 return $starttime_test_program;
59 }
60  
61 0 ▶sub _perl_gitversion {
Subroutine _perl_gitversion: not called CC=2 SCAR=17.9
62 0 my $perlpath = "$^X";
63 0 $perlpath =~ s,/[^/]*$,,;
64 0 my $perl_gitversion = "$perlpath/perl-gitversion";
65  
66 0 ▶ if (-x $perl_gitversion) {
Branch: 1 branch
BranchTrueFalseTotal
if (-x $perl_gitversion) 0 0 0
67 0 my $gitversion = qx!$perl_gitversion! ;
68 0 chomp $gitversion;
69 0 return $gitversion;
70 }
71 }
72  
73 0 ▶sub _suite_name {
Subroutine _suite_name: not called CC=2 SCAR=17.9
74 sprintf("benchmark-perlformance-%d.%d%s",
75 $Config{PERL_REVISION},
76 $Config{PERL_VERSION},
77 0 ▶ ($ENV{PERLFORMANCE_TESTMODE_FAST} ? "-fast" : ""),
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'PERLFORMANCE_TESTMODE_FAST'} ? : 0 0 0
78 );
79 }
80 0 ▶sub _suite_version { $Tapper::TestSuite::Benchmark::Perl::Formance::VERSION }
Subroutine _suite_version: not called CC=1 SCAR=6.9
81 0 ▶sub _suite_type { 'benchmark' }
Subroutine _suite_type: not called CC=1 SCAR=6.9
82 0 ▶sub _reportgroup_arbitrary { $ENV{TAPPER_REPORT_GROUP} }
Subroutine _reportgroup_arbitrary: not called CC=1 SCAR=6.9
83 0 ▶sub _reportgroup_testrun { $ENV{TAPPER_TESTRUN} }
Subroutine _reportgroup_testrun: not called CC=1 SCAR=6.9
84  
85 sub tapper_section_meta
86 0 ▶{
Subroutine tapper_section_meta: not called CC=3 SCAR=24.8
Pod documented
87 0 my $uname = _uname();
88 0 my $osname = _osname();
89 0 my $cpuinfo = _cpuinfo();
90 0 my $ram = _ram();
91 0 my $starttime_test_program = _starttime_test_program();
92 0 my $gitversion = _perl_gitversion();
93  
94 0 my $output = "";
95 0 $output .= "# Tapper-uname: $uname\n";
96 0 $output .= "# Tapper-osname: $osname\n";
97 0 $output .= "# Tapper-cpuinfo: $cpuinfo\n";
98 0 $output .= "# Tapper-ram: $ram\n";
99 0 $output .= "# Tapper-language-description: Perl-$]\n";
100 0 ▶ $output .= "# Tapper-changeset: $gitversion\n" if $gitversion;
Branch: 1 branch
BranchTrueFalseTotal
if $gitversion 0 0 0
101 0 $output .= "# Tapper-starttime-test-program: $starttime_test_program\n";
102 #$output .= "# Tapper-ticket-url: http://speed.perlformance.net/changes/?rev=$gitversion\n" if $gitversion;
103 0 ▶ $output .= "# Tapper-moreinfo-url: http://speed.perlformance.net/changes/?rev=$gitversion\n" if $gitversion;
Branch: 1 branch
BranchTrueFalseTotal
if $gitversion 0 0 0
104 0 return $output;
105 }
106  
107 sub tapper_suite_meta
108 0 ▶{
Subroutine tapper_suite_meta: not called CC=3 SCAR=24.8
Pod documented
109 0 my $suite_name = _suite_name();
110 0 my $suite_version = _suite_version();
111 0 my $suite_type = _suite_type();
112 0 my $hostname = _hostname();
113 0 my $reportgroup_arbitrary = _reportgroup_arbitrary();
114 0 my $reportgroup_testrun = _reportgroup_testrun();
115  
116 # to be used by Tapper::* modules
117  
118 0 my $output = "ok tapper-suite-meta\n";
119 0 ▶ $output .= "# Tapper-reportgroup-arbitrary: $reportgroup_arbitrary\n" if $reportgroup_arbitrary;
Branch: 1 branch
BranchTrueFalseTotal
if $reportgroup_arbitrary 0 0 0
120 0 ▶ $output .= "# Tapper-reportgroup-testrun: $reportgroup_testrun\n" if $reportgroup_testrun;
Branch: 1 branch
BranchTrueFalseTotal
if $reportgroup_testrun 0 0 0
121 0 $output .= "# Tapper-suite-name: $suite_name\n";
122 0 $output .= "# Tapper-suite-version: $suite_version\n";
123 0 $output .= "# Tapper-suite-type: $suite_type\n";
124 0 $output .= "# Tapper-machine-name: $hostname\n";
125  
126 0 return $output;
127 }
128  
129 sub usage
130 0 ▶{
Subroutine usage: not called CC=1 SCAR=6.9
Pod documented
131 0 print 'tapper-testsuite-perlformance - Tapper - Wrapper for Benchmark:Perl::Formance
132  
133 Usage:
134  
135 $ tapper-testsuite-perlformance -v
136 $ tapper-testsuite-perlformance --perlpath="/opt/bin/perl5.8.9"
137  
138 Options:
139  
140 -h | --help ... print this help screen
141 -v | --verbose ... some verbose messages to stdout
142 --perlpath ... complete call path of "perl" executable
143 --perlformancepath ... complete call path of "benchmark-perlformance" script
144 --plugins=Foo,Bar ... plugin list, passed through to benchmark-perlformance
145 ';
146 }
147  
148 sub get_options
149 0 ▶{
Subroutine get_options: not called CC=6 SCAR=37.4
Pod documented
150 0 my $help = 0;
151 0 my $verbose = 0;
152 0 my $plugins = "";
153 0 my $perlpath = "$^X";
154 0 my $perlformancepath = "";
155  
156 0 my $ok = GetOptions (
157 "help|h" => \$help,
158 "verbose|v+" => \$verbose,
159 "plugins=s" => \$plugins,
160 "perlpath=s" => \$perlpath,
161 "perlformancepath=s" => \$perlformancepath,
162 );
163  
164 0 ▶ do { usage; exit 0 } if $help;
Branch: 1 branch
BranchTrueFalseTotal
if ($help) 0 0 0
165 0 ▶ do { usage; exit -1 } if not $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 0 0 0
166  
167 0 ▶ if (not $perlformancepath) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($perlformancepath) 0 0 0
168 0 $perlformancepath = $perlpath;
169 0 $perlformancepath =~ s!^(.*)/[^/]+$!$1/benchmark-perlformance!;
170 }
171  
172 0 ▶ if ($plugins) {
Branch: 2 branches
BranchTrueFalseTotal
if ($plugins) { } 0 0 0
elsif ($ENV{'HARNESS_ACTIVE'}) { } 0 0 0
173 0 $plugins = "--plugins=$plugins";
174 } elsif ($ENV{HARNESS_ACTIVE}) {
175 0 $plugins = "--plugins=Shootout,DPath";
176 }
177  
178 return {
179 0 help => $help,
180 verbose => $verbose,
181 perlpath => $perlpath,
182 plugins => $plugins,
183 perlformancepath => $perlformancepath,
184 };
185 }
186  
187 0 ▶sub send_report {
Subroutine send_report: not called CC=5 SCAR=34.0
Pod documented
188 0 my ($report) = @_;
189  
190 0 my %cfg;
191 0 ▶ $cfg{report_server} = $ENV{TAPPER_REPORT_SERVER} || 'perlformance.net';
Condition0%0/2
$ENV{'TAPPER_REPORT_SERVER'} || 'perlformance.net'
l!l
00
MC/DC0%0/1
$ENV{'TAPPER_REPORT_SERVER'} || 'perlformance.net'
$ENV{'TAPPER_REPORT_SERVER'}
Truth table0%0/2
A
A= $ENV{'TAPPER_REPORT_SERVER'}
Aresult
11
00
192 0 ▶ $cfg{report_api_port} = $ENV{TAPPER_REPORT_API_PORT} || 7358;
Condition0%0/2
$ENV{'TAPPER_REPORT_API_PORT'} || 7358
l!l
00
MC/DC0%0/1
$ENV{'TAPPER_REPORT_API_PORT'} || 7358
$ENV{'TAPPER_REPORT_API_PORT'}
Truth table0%0/2
A
A= $ENV{'TAPPER_REPORT_API_PORT'}
Aresult
11
00
193 0 ▶ $cfg{report_port} = $ENV{TAPPER_REPORT_PORT} || 7357;
Condition0%0/2
$ENV{'TAPPER_REPORT_PORT'} || 7357
l!l
00
MC/DC0%0/1
$ENV{'TAPPER_REPORT_PORT'} || 7357
$ENV{'TAPPER_REPORT_PORT'}
Truth table0%0/2
A
A= $ENV{'TAPPER_REPORT_PORT'}
Aresult
11
00
194  
195 # following options are not yet used in this class
196 0 $cfg{mcp_server} = $ENV{TAPPER_SERVER};
197 0 $cfg{runtime} = $ENV{TAPPER_TS_RUNTIME};
198  
199 my $sock = IO::Socket::INET->new(PeerAddr => $cfg{report_server},
200 PeerPort => $cfg{report_port},
201 0 Proto => 'tcp');
202 0 ▶ if ($sock) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sock) { } 0 0 0
203 0 $sock->print($report);
204 0 $sock->close;
205 } else {
206 0 warn "# Can't open connection to ", $cfg{report_server}, " ($!)";
207 }
208 0 return 0;
209 }
210  
211 sub PerlFormanceResults
212 0 ▶{
Subroutine PerlFormanceResults: not called CC=3 SCAR=24.8
Pod documented
213 0 my ($options) = @_;
214  
215 0 my $perlformancepath = $options->{perlformancepath};
216 0 my ($plugins, $verbose) = @$options{qw(plugins verbose)};
217 0 ▶ my $fastmode = ($ENV{PERLFORMANCE_TESTMODE_FAST} ? "--fastmode" : "");
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'PERLFORMANCE_TESTMODE_FAST'} ? : 0 0 0
218 0 my $cmd = "$^X $perlformancepath --tapdescription='benchmarks' $fastmode -ccc -v -p --outstyle=yaml --indent=2 $plugins --codespeed 2>&1";
219 0 ▶ print STDERR "# $cmd\n" if $verbose >= 2;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose >= 2 0 0 0
220 0 my $yaml = qx!$cmd!;
221 0 return $yaml;
222 }
223  
224 0 ▶sub main {
Subroutine main: not called CC=3 SCAR=24.8
Pod documented
225 0 my $options = get_options;
226  
227 0 my $output = "TAP Version 13\n";
228  
229 0 $output .= "1..1\n";
230 0 $output .= "# Tapper-Section: metainfo\n";
231 0 ▶ $output .= tapper_suite_meta || "";
Condition0%0/2
tapper_suite_meta() || ''
l!l
00
MC/DC0%0/1
tapper_suite_meta() || ''
tapper_suite_meta()
Truth table0%0/2
A
A= tapper_suite_meta()
Aresult
11
00
232 0 ▶ $output .= tapper_section_meta || "";
Condition0%0/2
tapper_section_meta() || ''
l!l
00
MC/DC0%0/1
tapper_section_meta() || ''
tapper_section_meta()
Truth table0%0/2
A
A= tapper_section_meta()
Aresult
11
00
233  
234 0 $output .= "1..1\n";
235 0 $output .= "# Tapper-Section: results\n";
236 0 $output .= PerlFormanceResults($options);
237  
238 0 return $output;
239 }
240  
241 sub run
242 0 ▶{
Subroutine run: not called CC=2 SCAR=17.9
Pod documented
243 0 my $output = main;
244 0 print $output;
245 0 ▶ send_report($output) unless $ENV{HARNESS_ACTIVE};
Branch: 1 branch
BranchTrueFalseTotal
unless $ENV{"HARNESS_ACTIVE"} 0 0 0
246 }
247  
248 1 1; # End of Tapper::TestSuite::Benchmark::Perl::Formance
249  
250  
251  
252 =pod
253  
254 =encoding utf-8
255  
256 =head1 NAME
257  
258 Tapper::TestSuite::Benchmark::Perl::Formance - Tapper - Wrapper for Benchmark::Perl::Formance
259  
260 =head1 SYNOPSIS
261  
262 You most likely want to run the frontend cmdline tool like this
263  
264 $ tapper-testsuite-benchmark-perl-formance -vvv
265  
266 =head1 DESCRIPTION
267  
268 This is a Tapper wrapper for L<Benchmark::Perl::Formance>.
269  
270 =head1 FUNCTIONS
271  
272 =head2 PerlFormanceResults
273  
274 =head2 tapper_section_meta
275  
276 =head2 tapper_suite_meta
277  
278 =head2 send_report
279  
280 =head2 get_options
281  
282 =head2 main
283  
284 =head2 run
285  
286 =head2 usage
287  
288 =head1 AUTHOR
289  
290 AMD OSRC Tapper Team <tapper@amd64.org>
291  
292 =head1 COPYRIGHT AND LICENSE
293  
294 This software is Copyright (c) 2012 by Advanced Micro Devices, Inc..
295  
296 This is free software, licensed under:
297  
298 The (two-clause) FreeBSD License
299  
300 =cut
301  
302  
303 __END__
↑ Summary