← Index
NYTProf Performance Profile   « line view »
For bin/benchmark-perlformance
  Run on Fri Apr 17 15:31:48 2015
Reported on Fri Apr 17 15:32:02 2015

Filename/home/ss5/local/projects/Benchmark-Perl-Formance/lib/Benchmark/Perl/Formance.pm
StatementsExecuted 177 statements in 105ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11197.4ms5.54sBenchmark::Perl::Formance::::run_pluginBenchmark::Perl::Formance::run_plugin
1116.45ms7.10msBenchmark::Perl::Formance::::BEGIN@18Benchmark::Perl::Formance::BEGIN@18
1116.06ms23.0msBenchmark::Perl::Formance::::BEGIN@11Benchmark::Perl::Formance::BEGIN@11
1112.36ms9.97msBenchmark::Perl::Formance::::BEGIN@12Benchmark::Perl::Formance::BEGIN@12
1111.41ms1.44msBenchmark::Perl::Formance::::BEGIN@5Benchmark::Perl::Formance::BEGIN@5
1111.36ms2.21msBenchmark::Perl::Formance::::BEGIN@9Benchmark::Perl::Formance::BEGIN@9
111604µs4.50msBenchmark::Perl::Formance::::BEGIN@21Benchmark::Perl::Formance::BEGIN@21
111543µs656µsBenchmark::Perl::Formance::::BEGIN@13Benchmark::Perl::Formance::BEGIN@13
111463µs866µsBenchmark::Perl::Formance::::BEGIN@22Benchmark::Perl::Formance::BEGIN@22
111449µs669µsBenchmark::Perl::Formance::::BEGIN@20Benchmark::Perl::Formance::BEGIN@20
111436µs826µsBenchmark::Perl::Formance::::BEGIN@14Benchmark::Perl::Formance::BEGIN@14
111430µs1.07msBenchmark::Perl::Formance::::BEGIN@8Benchmark::Perl::Formance::BEGIN@8
111387µs53.3msBenchmark::Perl::Formance::::BEGIN@17Benchmark::Perl::Formance::BEGIN@17
111365µs365µsBenchmark::Perl::Formance::::CORE:openBenchmark::Perl::Formance::CORE:open (opcode)
111274µs336µsBenchmark::Perl::Formance::::BEGIN@15Benchmark::Perl::Formance::BEGIN@15
111238µs268µsBenchmark::Perl::Formance::::BEGIN@6Benchmark::Perl::Formance::BEGIN@6
111218µs7.70msBenchmark::Perl::Formance::::find_interesting_result_pathsBenchmark::Perl::Formance::find_interesting_result_paths
111208µs471µsBenchmark::Perl::Formance::::BEGIN@16Benchmark::Perl::Formance::BEGIN@16
111191µs5.55sBenchmark::Perl::Formance::::runBenchmark::Perl::Formance::run
111113µs10.2msBenchmark::Perl::Formance::::print_outstyle_summaryBenchmark::Perl::Formance::print_outstyle_summary
22165µs65µsBenchmark::Perl::Formance::::CORE:sortBenchmark::Perl::Formance::CORE:sort (opcode)
21151µs51µsBenchmark::Perl::Formance::::CORE:printBenchmark::Perl::Formance::CORE:print (opcode)
11132µs10.2msBenchmark::Perl::Formance::::print_resultsBenchmark::Perl::Formance::print_results
11124µs24µsBenchmark::Perl::Formance::::BEGIN@3Benchmark::Perl::Formance::BEGIN@3
22120µs20µsBenchmark::Perl::Formance::::CORE:closeBenchmark::Perl::Formance::CORE:close (opcode)
22110µs10µsBenchmark::Perl::Formance::::CORE:qrBenchmark::Perl::Formance::CORE:qr (opcode)
11110µs10µsBenchmark::Perl::Formance::::newBenchmark::Perl::Formance::new
11110µs19µsBenchmark::Perl::Formance::::BEGIN@155Benchmark::Perl::Formance::BEGIN@155
1119µs21µsBenchmark::Perl::Formance::::BEGIN@265Benchmark::Perl::Formance::BEGIN@265
1119µs35µsBenchmark::Perl::Formance::::BEGIN@19Benchmark::Perl::Formance::BEGIN@19
1118µs18µsBenchmark::Perl::Formance::::BEGIN@478Benchmark::Perl::Formance::BEGIN@478
2218µs8µsBenchmark::Perl::Formance::::CORE:matchBenchmark::Perl::Formance::CORE:match (opcode)
1118µs18µsBenchmark::Perl::Formance::::BEGIN@723Benchmark::Perl::Formance::BEGIN@723
1118µs17µsBenchmark::Perl::Formance::::BEGIN@261Benchmark::Perl::Formance::BEGIN@261
1117µs18µsBenchmark::Perl::Formance::::BEGIN@10Benchmark::Perl::Formance::BEGIN@10
1117µs7µsBenchmark::Perl::Formance::::prepare_fast_systemBenchmark::Perl::Formance::prepare_fast_system
2213µs3µsBenchmark::Perl::Formance::::CORE:regcompBenchmark::Perl::Formance::CORE:regcomp (opcode)
1113µs3µsBenchmark::Perl::Formance::::prepare_stable_systemBenchmark::Perl::Formance::prepare_stable_system
1111µs1µsBenchmark::Perl::Formance::::CORE:substBenchmark::Perl::Formance::CORE:subst (opcode)
0000s0sBenchmark::Perl::Formance::::__ANON__[lib/Benchmark/Perl/Formance.pm:168]Benchmark::Perl::Formance::__ANON__[lib/Benchmark/Perl/Formance.pm:168]
0000s0sBenchmark::Perl::Formance::::__ANON__[lib/Benchmark/Perl/Formance.pm:675]Benchmark::Perl::Formance::__ANON__[lib/Benchmark/Perl/Formance.pm:675]
0000s0sBenchmark::Perl::Formance::::_codespeed_metaBenchmark::Perl::Formance::_codespeed_meta
0000s0sBenchmark::Perl::Formance::::_get_bootstrap_perl_metaBenchmark::Perl::Formance::_get_bootstrap_perl_meta
0000s0sBenchmark::Perl::Formance::::_get_hostnameBenchmark::Perl::Formance::_get_hostname
0000s0sBenchmark::Perl::Formance::::_get_perl_configBenchmark::Perl::Formance::_get_perl_config
0000s0sBenchmark::Perl::Formance::::_get_perl_config_vBenchmark::Perl::Formance::_get_perl_config_v
0000s0sBenchmark::Perl::Formance::::_get_perlformance_configBenchmark::Perl::Formance::_get_perlformance_config
0000s0sBenchmark::Perl::Formance::::_get_platforminfoBenchmark::Perl::Formance::_get_platforminfo
0000s0sBenchmark::Perl::Formance::::_get_sysinfoBenchmark::Perl::Formance::_get_sysinfo
0000s0sBenchmark::Perl::Formance::::_perl_gitdescribeBenchmark::Perl::Formance::_perl_gitdescribe
0000s0sBenchmark::Perl::Formance::::_perl_gitversionBenchmark::Perl::Formance::_perl_gitversion
0000s0sBenchmark::Perl::Formance::::_perl_symbolic_nameBenchmark::Perl::Formance::_perl_symbolic_name
0000s0sBenchmark::Perl::Formance::::_plugin_resultsBenchmark::Perl::Formance::_plugin_results
0000s0sBenchmark::Perl::Formance::::augment_results_with_metaBenchmark::Perl::Formance::augment_results_with_meta
0000s0sBenchmark::Perl::Formance::::do_disk_syncBenchmark::Perl::Formance::do_disk_sync
0000s0sBenchmark::Perl::Formance::::generate_BenchmarkAnythingData_dataBenchmark::Perl::Formance::generate_BenchmarkAnythingData_data
0000s0sBenchmark::Perl::Formance::::generate_codespeed_dataBenchmark::Perl::Formance::generate_codespeed_data
0000s0sBenchmark::Perl::Formance::::load_all_pluginsBenchmark::Perl::Formance::load_all_plugins
0000s0sBenchmark::Perl::Formance::::print_outstyle_jsonBenchmark::Perl::Formance::print_outstyle_json
0000s0sBenchmark::Perl::Formance::::print_outstyle_yamlBenchmark::Perl::Formance::print_outstyle_yaml
0000s0sBenchmark::Perl::Formance::::print_versionBenchmark::Perl::Formance::print_version
0000s0sBenchmark::Perl::Formance::::restore_stable_systemBenchmark::Perl::Formance::restore_stable_system
0000s0sBenchmark::Perl::Formance::::usageBenchmark::Perl::Formance::usage
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Benchmark::Perl::Formance;
2
3253µs124µs
# spent 24µs within Benchmark::Perl::Formance::BEGIN@3 which was called: # once (24µs+0s) by main::BEGIN@5 at line 3
use 5.008;
# spent 24µs making 1 call to Benchmark::Perl::Formance::BEGIN@3
4
521.32ms21.45ms
# spent 1.44ms (1.41+27µs) within Benchmark::Perl::Formance::BEGIN@5 which was called: # once (1.41ms+27µs) by main::BEGIN@5 at line 5
use warnings;
# spent 1.44ms making 1 call to Benchmark::Perl::Formance::BEGIN@5 # spent 6µs making 1 call to warnings::import
62237µs2286µs
# spent 268µs (238+30) within Benchmark::Perl::Formance::BEGIN@6 which was called: # once (238µs+30µs) by main::BEGIN@5 at line 6
use strict;
# spent 268µs making 1 call to Benchmark::Perl::Formance::BEGIN@6 # spent 17µs making 1 call to strict::import
7
8279µs21.08ms
# spent 1.07ms (430µs+638µs) within Benchmark::Perl::Formance::BEGIN@8 which was called: # once (430µs+638µs) by main::BEGIN@5 at line 8
use Config;
# spent 1.07ms making 1 call to Benchmark::Perl::Formance::BEGIN@8 # spent 10µs making 1 call to Config::import
92108µs22.23ms
# spent 2.21ms (1.36+853µs) within Benchmark::Perl::Formance::BEGIN@9 which was called: # once (1.36ms+853µs) by main::BEGIN@5 at line 9
use Config::Perl::V;
# spent 2.21ms making 1 call to Benchmark::Perl::Formance::BEGIN@9 # spent 15µs making 1 call to Exporter::import
10220µs228µs
# spent 18µs (7+10) within Benchmark::Perl::Formance::BEGIN@10 which was called: # once (7µs+10µs) by main::BEGIN@5 at line 10
use Exporter;
# spent 18µs making 1 call to Benchmark::Perl::Formance::BEGIN@10 # spent 10µs making 1 call to Exporter::import
11286µs224.4ms
# spent 23.0ms (6.06+16.9) within Benchmark::Perl::Formance::BEGIN@11 which was called: # once (6.06ms+16.9ms) by main::BEGIN@5 at line 11
use Getopt::Long ":config", "no_ignore_case", "bundling";
# spent 23.0ms making 1 call to Benchmark::Perl::Formance::BEGIN@11 # spent 1.42ms making 1 call to Getopt::Long::import
12288µs210.0ms
# spent 9.97ms (2.36+7.62) within Benchmark::Perl::Formance::BEGIN@12 which was called: # once (2.36ms+7.62ms) by main::BEGIN@5 at line 12
use Data::Structure::Util "unbless";
# spent 9.97ms making 1 call to Benchmark::Perl::Formance::BEGIN@12 # spent 48µs making 1 call to Exporter::import
13280µs1656µs
# spent 656µs (543+112) within Benchmark::Perl::Formance::BEGIN@13 which was called: # once (543µs+112µs) by main::BEGIN@5 at line 13
use Data::YAML::Writer;
# spent 656µs making 1 call to Benchmark::Perl::Formance::BEGIN@13
14288µs2986µs
# spent 826µs (436+389) within Benchmark::Perl::Formance::BEGIN@14 which was called: # once (436µs+389µs) by main::BEGIN@5 at line 14
use Time::HiRes qw(gettimeofday);
# spent 826µs making 1 call to Benchmark::Perl::Formance::BEGIN@14 # spent 160µs making 1 call to Time::HiRes::import
15277µs1336µs
# spent 336µs (274+62) within Benchmark::Perl::Formance::BEGIN@15 which was called: # once (274µs+62µs) by main::BEGIN@5 at line 15
use Devel::Platform::Info;
# spent 336µs making 1 call to Benchmark::Perl::Formance::BEGIN@15
16276µs2478µs
# spent 471µs (208+262) within Benchmark::Perl::Formance::BEGIN@16 which was called: # once (208µs+262µs) by main::BEGIN@5 at line 16
use List::Util "max";
# spent 471µs making 1 call to Benchmark::Perl::Formance::BEGIN@16 # spent 7µs making 1 call to List::Util::import
17288µs253.5ms
# spent 53.3ms (387µs+52.9) within Benchmark::Perl::Formance::BEGIN@17 which was called: # once (387µs+52.9ms) by main::BEGIN@5 at line 17
use Data::DPath 'dpath', 'dpathi';
# spent 53.3ms making 1 call to Benchmark::Perl::Formance::BEGIN@17 # spent 163µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
18291µs27.13ms
# spent 7.10ms (6.45+643µs) within Benchmark::Perl::Formance::BEGIN@18 which was called: # once (6.45ms+643µs) by main::BEGIN@5 at line 18
use File::Find;
# spent 7.10ms making 1 call to Benchmark::Perl::Formance::BEGIN@18 # spent 38µs making 1 call to Exporter::import
19222µs262µs
# spent 35µs (9+27) within Benchmark::Perl::Formance::BEGIN@19 which was called: # once (9µs+27µs) by main::BEGIN@5 at line 19
use Storable "fd_retrieve", "store_fd";
# spent 35µs making 1 call to Benchmark::Perl::Formance::BEGIN@19 # spent 27µs making 1 call to Exporter::import
20274µs2691µs
# spent 669µs (449+221) within Benchmark::Perl::Formance::BEGIN@20 which was called: # once (449µs+221µs) by main::BEGIN@5 at line 20
use Sys::Hostname;
# spent 669µs making 1 call to Benchmark::Perl::Formance::BEGIN@20 # spent 21µs making 1 call to Exporter::import
21271µs24.50ms
# spent 4.50ms (604µs+3.89) within Benchmark::Perl::Formance::BEGIN@21 which was called: # once (604µs+3.89ms) by main::BEGIN@5 at line 21
use Sys::Info;
# spent 4.50ms making 1 call to Benchmark::Perl::Formance::BEGIN@21 # spent 5µs making 1 call to Sys::Info::import
222261µs2946µs
# spent 866µs (463+402) within Benchmark::Perl::Formance::BEGIN@22 which was called: # once (463µs+402µs) by main::BEGIN@5 at line 22
use FindBin qw($Bin);
# spent 866µs making 1 call to Benchmark::Perl::Formance::BEGIN@22 # spent 81µs making 1 call to Exporter::import
23
24# comma separated list of default plugins
2512µsmy $DEFAULT_PLUGINS = join ",", qw(DPath
26 Fib
27 FibOO
28 Mem
29 Prime
30 Rx
31 Shootout::fasta
32 Shootout::regexdna
33 Shootout::binarytrees
34 Shootout::revcomp
35 Shootout::nbody
36 Shootout::spectralnorm
37 );
38
39# FibMXDeclare
4012µsmy $ALL_PLUGINS = join ",", qw(DPath
41 Fib
42 FibMoose
43 FibMouse
44 FibOO
45 Mem
46 P6STD
47 PerlCritic
48 Prime
49 RegexpCommonTS
50 Rx
51 RxCmp
52 Shootout::binarytrees
53 Shootout::fannkuch
54 Shootout::fasta
55 Shootout::knucleotide
56 Shootout::mandelbrot
57 Shootout::nbody
58 Shootout::pidigits
59 Shootout::regexdna
60 Shootout::revcomp
61 Shootout::spectralnorm
62 SpamAssassin
63 Threads
64 ThreadsShared
65 );
66
671800nsour $scaling_script = "$Bin/benchmark-perlformance-set-stable-system";
68
691200nsour $DEFAULT_INDENT = 0;
70
711100nsmy @run_plugins;
72
73# incrementaly interesting Perl Config keys
7411.79ms11123.01msmy %CONFIG_KEYS = (
# spent 1.52ms making 1110 calls to Config::NEXTKEY, avg 1µs/call # spent 1.42ms making 1 call to Config::AUTOLOAD # spent 62µs making 1 call to Benchmark::Perl::Formance::CORE:sort
75 0 => [],
76 1 => [
77 qw(perlpath
78 version
79 archname
80 archname64
81 osvers
82 usethreads
83 useithreads
84 )],
85 2 => [
86 qw(gccversion
87 gnulibc_version
88 usemymalloc
89 config_args
90 optimize
91 )],
92 3 => [qw(ccflags
93 ccname
94 cccdlflags
95 ccdlflags
96 cppflags
97 nm_so_opt
98 )],
99 4 => [qw(PERL_REVISION
100 PERL_VERSION
101 PERL_SUBVERSION
102 PERL_PATCHLEVEL
103
104 api_revision
105 api_version
106 api_subversion
107 api_versionstring
108
109 gnulibc_version
110 dtrace
111 doublesize
112 alignbytes
113 bin_ELF
114 git_commit_date
115 version_patchlevel_string
116 d_mymalloc
117
118 i16size
119 i16type
120 i32size
121 i32type
122 i64size
123 i64type
124 i8size
125 i8type
126
127 longdblsize
128 longlongsize
129 longsize
130
131 perllibs
132 ptrsize
133 quadkind
134 quadtype
135 randbits
136 )],
137 5 => [
138 sort keys %Config
139 ],
140 );
141
142
# spent 10µs within Benchmark::Perl::Formance::new which was called: # once (10µs+0s) by main::RUNTIME at line 7 of bin/benchmark-perlformance
sub new {
14312µs my ($class, %args) = @_;
144111µs bless { %args }, $class;
145}
146
147sub load_all_plugins
148{
149 my $path = __FILE__;
150 $path =~ s,\.pmc?$,/Plugin,;
151
152 my %all_plugins;
153 finddepth ({ no_chdir => 1,
154 follow => 1,
1552351µs228µs
# spent 19µs (10+9) within Benchmark::Perl::Formance::BEGIN@155 which was called: # once (10µs+9µs) by main::BEGIN@5 at line 155
wanted => sub { no strict 'refs';
# spent 19µs making 1 call to Benchmark::Perl::Formance::BEGIN@155 # spent 9µs making 1 call to strict::unimport
156 my $fullname = $File::Find::fullname;
157 my $plugin = $File::Find::name;
158 $plugin =~ s,^$path/*,,;
159 $plugin =~ s,/,::,;
160 $plugin =~ s,\.pmc?$,,;
161
162 my $module = "Benchmark::Perl::Formance::Plugin::$plugin";
163 # eval { require $fullname };
164 eval "use $module"; ## no critic
165 my $version = $@ ? "~" : ${$module."::VERSION"};
166 $all_plugins{$plugin} = $version
167 if -f $fullname && $fullname =~ /\.pmc?$/;
168 },
169 },
170 $path);
171 return %all_plugins;
172}
173
174sub print_version
175{
176 my ($self) = @_;
177
178 if ($self->{options}{verbose})
179 {
180 print "Benchmark::Perl::Formance version $Benchmark::Perl::Formance::VERSION\n";
181 print "Plugins:\n";
182 my %plugins = load_all_plugins;
183 print " (v$plugins{$_}) $_\n" foreach sort keys %plugins;
184 }
185 else
186 {
187 print $Benchmark::Perl::Formance::VERSION, "\n";
188 }
189}
190
191sub usage
192{
193 print 'benchmark-perlformance - Frontend for Benchmark::Perl::Formance
194
195Usage:
196
197 $ benchmark-perlformance
198 $ benchmark-perlformance --fastmode
199 $ benchmark-perlformance --useforks
200 $ benchmark-perlformance --plugins=SpamAssassin,RegexpCommonTS,RxCmp -v
201 $ benchmark-perlformance -ccccc --indent=2
202 $ benchmark-perlformance -q
203
204If run directly it uses the perl in your PATH:
205
206 $ /path/to/benchmark-perlformance
207
208To use another perl start it via
209
210 $ /other/path/to/bin/perl /path/to/benchmark-perlformance
211
212For more details see
213
214 man benchmark-perlformance
215 perldoc Benchmark::Perl::Formance
216
217';
218}
219
220sub do_disk_sync {
221 system("sync ; sync");
222}
223
224sub prepare_stable_system
225
# spent 3µs within Benchmark::Perl::Formance::prepare_stable_system which was called: # once (3µs+0s) by Benchmark::Perl::Formance::run at line 617
{
2261600ns my ($self) = @_;
227
2281200ns my $orig_values;
22914µs if ($self->{options}{stabilize_cpu} and $^O eq "linux") {
230 $self->{orig_system_values} = qx(sudo $scaling_script lo);
231 do_disk_sync();
232 }
233}
234
235sub restore_stable_system
236{
237 my ($self, $orig_values) = @_;
238 if ($self->{options}{stabilize_cpu} and $^O eq "linux") {
239 if (open my $RESTORE, "|-", "sudo $scaling_script restore") {
240 print $RESTORE $self->{orig_system_values};
241 close $RESTORE;
242 }
243 }
244}
245
246sub prepare_fast_system
247
# spent 7µs within Benchmark::Perl::Formance::prepare_fast_system which was called: # once (7µs+0s) by Benchmark::Perl::Formance::run at line 624
{
2481900ns my ($self) = @_;
249
2501300ns my $orig_values;
25119µs if ($self->{options}{stabilize_cpu} and $^O eq "linux") {
252 $self->{orig_system_values} = qx(sudo $scaling_script hi);
253 }
254}
255
256sub run_plugin
257
# spent 5.54s (97.4ms+5.45) within Benchmark::Perl::Formance::run_plugin which was called: # once (97.4ms+5.45s) by Benchmark::Perl::Formance::run at line 621
{
25811µs my ($self, $pluginname) = @_;
259
26018µs11µs $pluginname =~ s,\.,::,g;
# spent 1µs making 1 call to Benchmark::Perl::Formance::CORE:subst
261249µs226µs
# spent 17µs (8+9) within Benchmark::Perl::Formance::BEGIN@261 which was called: # once (8µs+9µs) by main::BEGIN@5 at line 261
no strict 'refs'; ## no critic
# spent 17µs making 1 call to Benchmark::Perl::Formance::BEGIN@261 # spent 9µs making 1 call to strict::unimport
26211µs print STDERR "# Run $pluginname...\n" if $self->{options}{verbose} >= 2;
2631200ns my $res;
26412µs eval {
2652899µs233µs
# spent 21µs (9+12) within Benchmark::Perl::Formance::BEGIN@265 which was called: # once (9µs+12µs) by main::BEGIN@5 at line 265
use IO::Handle;
# spent 21µs making 1 call to Benchmark::Perl::Formance::BEGIN@265 # spent 12µs making 1 call to Exporter::import
266115µs pipe(PARENT_RDR, CHILD_WTR);
267114µs278µs CHILD_WTR->autoflush(1);
# spent 69µs making 1 call to IO::Handle::autoflush # spent 9µs making 1 call to SelectSaver::DESTROY
2681438µs1365µs my $pid = open(my $PLUGIN, "-|"); # implicit fork
# spent 365µs making 1 call to Benchmark::Perl::Formance::CORE:open
2691400ns if ($pid == 0) {
270 # run in child process
271 close PARENT_RDR;
272 eval "use Benchmark::Perl::Formance::Plugin::$pluginname"; ## no critic
273 if ($@) {
274 my @errors = split qr/\n/, $@;
275 my $maxerr = ($#errors < 10) ? $#errors : 10;
276 print STDERR "# Skip plugin '$pluginname'" if $self->{options}{verbose};
277 print STDERR ":".$errors[0] if $self->{options}{verbose} > 1;
278 print STDERR join("\n# ", "", @errors[1..$maxerr]) if $self->{options}{verbose} > 2;
279 print STDERR "\n" if $self->{options}{verbose};
280 exit 0;
281 }
282 $0 = "benchmark-perl-formance-$pluginname";
283 $res = &{"Benchmark::Perl::Formance::Plugin::${pluginname}::main"}($self->{options});
284 $res->{PLUGIN_VERSION} = ${"Benchmark::Perl::Formance::Plugin::${pluginname}::VERSION"};
285 store_fd($res, \*CHILD_WTR);
286 close CHILD_WTR;
287 exit 0;
288 }
289125µs18µs close CHILD_WTR;
# spent 8µs making 1 call to Benchmark::Perl::Formance::CORE:close
290133µs15.45s $res = fd_retrieve(\*PARENT_RDR);
# spent 5.45s making 1 call to Storable::fd_retrieve
291197.3ms111µs close PARENT_RDR;
# spent 11µs making 1 call to Benchmark::Perl::Formance::CORE:close
292 };
2931400ns if ($@) {
294 $res = {
295 failed => "Plugin $pluginname failed",
296 ($self->{options}{verbose} > 3 ? ( error => $@ ) : ()),
297 }
298 }
299120µs return $res;
300}
301
302# That's specific to the Tapper wrapper around
303# Benchmark::Perl::Formance and should be replaced
304# with something generic
305sub _perl_gitversion {
306 my $perlpath = "$^X";
307 $perlpath =~ s,/[^/]*$,,;
308 my $perl_gitversion = "$perlpath/perl -MConfig -e 'print \$Config{bootstrap_perl_git_changeset}";
309
310 if (-x $perl_gitversion) {
311 my $gitversion = qx!$perl_gitversion! ;
312 chomp $gitversion;
313 return $gitversion;
314 }
315}
316
317sub _perl_gitdescribe {
318 my $perlpath = "$^X";
319 $perlpath =~ s,/[^/]*$,,;
320 my $perl_gitdescribe = "$perlpath/perl -MConfig -e 'print \$Config{bootstrap_perl_git_describe}";
321
322 if (-x $perl_gitdescribe) {
323 my $gitdescribe = qx!$perl_gitdescribe! ;
324 chomp $gitdescribe;
325 return $gitdescribe;
326 }
327}
328
329sub _perl_symbolic_name {
330 my $perlpath = "$^X";
331 $perlpath =~ s,/[^/]*$,,;
332 my $perl_symbolic_name = "$perlpath/perl -MConfig -e 'print \$Config{bootstrap_perl_symbolic_name}";
333
334 if (-x $perl_symbolic_name) {
335 my $executable = qx!$perl_symbolic_name! ;
336 chomp $executable;
337 return $executable;
338 }
339}
340
341sub _get_hostname {
342 my $host = "unknown-hostname";
343 eval { $host = hostname };
344 $host = "perl64.org" if $host eq "h1891504"; # special case for PerlFormance.Net Æsthetics
345 return $host;
346}
347
348sub _plugin_results {
349 my ($self, $plugin, $RESULTS) = @_;
350
351 my @resultkeys = split(/\./, $plugin);
352 my ($res) = dpath("/results/".join("/", map { qq("$_") } @resultkeys)."/Benchmark/*[0]")->match($RESULTS);
353
354 return $res;
355}
356
357sub _codespeed_meta {
358 my ($self, $RESULTS) = @_;
359
360 my $codespeed_exe_suffix = $self->{options}{cs_executable_suffix} || $ENV{CODESPEED_EXE_SUFFIX} || "";
361 my $codespeed_exe = $self->{options}{cs_executable} || _perl_symbolic_name || sprintf("perl-%s.%s%s",
362 $Config{PERL_REVISION},
363 $Config{PERL_VERSION},
364 $codespeed_exe_suffix,
365 );
366 my $codespeed_project = $self->{options}{cs_project} || $ENV{CODESPEED_PROJECT} || "perl5";
367 my $codespeed_branch = $self->{options}{cs_branch} || $ENV{CODESPEED_BRANCH} || "default";
368 my $codespeed_commitid = $self->{options}{cs_commitid} || $ENV{CODESPEED_COMMITID} || $Config{git_commit_id} || _perl_gitversion || "no-commit";
369 my $codespeed_environment = $self->{options}{cs_environment} || $ENV{CODESPEED_ENVIRONMENT} || _get_hostname || "no-env";
370 my %codespeed_meta = (
371 executable => $codespeed_exe,
372 project => $codespeed_project,
373 branch => $codespeed_branch,
374 commitid => $codespeed_commitid,
375 environment => $codespeed_environment,
376 );
377
378 return %codespeed_meta;
379}
380
381sub _get_bootstrap_perl_meta {
382 my ($self) = @_;
383
384 return map { ("$_" => $Config{$_}) } grep { /^bootstrap_perl/ } keys %Config;
385}
386
387sub _get_perl_config {
388 my ($self) = @_;
389
390 my @cfgkeys;
391 my $showconfig = 4;
392 push @cfgkeys, @{$CONFIG_KEYS{$_}} foreach 1..$showconfig;
393 return map { ("perlconfig_$_" => $Config{$_}) } @cfgkeys;
394}
395
396sub _get_perl_config_v {
397 my ($self) = @_;
398
399 # only when ultimate verbose config requested
400 return unless $self->{options}{showconfig} >= 5;
401
402 my $config_v_myconfig = Config::Perl::V::myconfig ();
403 my @config_v_keys = sort keys %$config_v_myconfig;
404
405 # --- flat configs ---
406 my $prefix = "perlconfigv";
407 my %perlconfigv = ();
408 my %focus = (
409 derived => [ qw( Off_t uname) ],
410 build => [ qw( osname stamp ) ],
411 environment => [ keys %{$config_v_myconfig->{environment}} ], # all
412 );
413 foreach my $subcfg (keys %focus) {
414 foreach my $k (@{$focus{$subcfg}}) {
415 $perlconfigv{join("_", $prefix, $subcfg, $k)} = $config_v_myconfig->{$subcfg}{$k};
416 }
417 }
418
419 # --- nested configs ---
420
421 # build options
422 my @buildoptionkeys = keys %{$config_v_myconfig->{build}{options}};
423 foreach my $k (keys %focus) {
424 $perlconfigv{join("_", $prefix, "build", "options", $k)} = $config_v_myconfig->{build}{options}{$k};
425 }
426
427 return %perlconfigv;
428}
429
430sub _get_perlformance_config {
431 my ($self) = @_;
432
433 # only easy printable data (i.e., no "D" hash)
434 my @config_keys = (qw(stabilize_cpu
435 fastmode
436 useforks
437 plugins
438 ));
439
440 return map { $self->{options}{$_} ? ("perlformance_$_" => $self->{options}{$_}) : () } @config_keys;
441}
442
443sub _get_platforminfo {
444 my ($self) = @_;
445
446 my $get_info = Devel::Platform::Info->new->get_info;
447 delete $get_info->{source}; # this currently breaks the simplified YAMLish
448 return %$get_info;
449}
450
451sub _get_sysinfo {
452 my ($self) = @_;
453
454 my %sysinfo = ();
455 my $prefix = "sysinfo";
456 my $cpu = (Sys::Info->new->device("CPU")->identify)[0];
457 $sysinfo{join("_", $prefix, "cpu", $_)} = $cpu->{$_} foreach qw(name
458 family
459 model
460 stepping
461 architecture
462 number_of_cores
463 number_of_logical_processors
464 architecture
465 manufacturer
466 );
467 $sysinfo{join("_", $prefix, "cpu", "l2_cache", "max_cache_size")} = $cpu->{L2_cache}{max_cache_size};
468 return %sysinfo;
469}
470
471sub augment_results_with_meta {
472 my ($self, $NAME_KEY, $VALUE_KEY, $META, $RESULTS) = @_;
473
474 my @run_plugins = $self->find_interesting_result_paths($RESULTS);
475 my @new_entries = ();
476 my $prefix = "perlformance.perl5";
477 foreach my $plugin (sort @run_plugins) {
4782786µs228µs
# spent 18µs (8+10) within Benchmark::Perl::Formance::BEGIN@478 which was called: # once (8µs+10µs) by main::BEGIN@5 at line 478
no strict 'refs'; ## no critic
# spent 18µs making 1 call to Benchmark::Perl::Formance::BEGIN@478 # spent 10µs making 1 call to strict::unimport
479 my $res = $self->_plugin_results($plugin, $RESULTS);
480 my $benchmark = join ".", $prefix, ($self->{options}{fastmode} ? "$plugin(F)" : $plugin);
481 push @new_entries, {
482 %$META,
483 # metric name and value at last position to override
484 $NAME_KEY => $benchmark,
485 $VALUE_KEY => ($res || 0),
486 };
487 }
488 return \@new_entries;
489}
490
491sub generate_codespeed_data
492{
493 my ($self, $RESULTS) = @_;
494
495 my %META = _codespeed_meta();
496 return $self->augment_results_with_meta("benchmark", "result_value", \%META, $RESULTS);
497}
498
499sub generate_BenchmarkAnythingData_data
500{
501 my ($self, $RESULTS) = @_;
502
503 # share a common dataset with Codespeed, yet prefix it
504 my %codespeed_meta = _codespeed_meta;
505 my %prefixed_codespeed_meta = map { ("codespeed_$_" => $codespeed_meta{$_}) } keys %codespeed_meta;
506
507 my %platforminfo = $self->_get_platforminfo;
508 my %prefixed_platforminfo = map { ("platforminfo_$_" => $platforminfo{$_}) } keys %platforminfo;
509
510 my %META = (
511 %prefixed_platforminfo,
512 %prefixed_codespeed_meta,
513 $self->_get_bootstrap_perl_meta,
514 $self->_get_perl_config,
515 $self->_get_perl_config_v,
516 $self->_get_sysinfo,
517 $self->_get_perlformance_config,
518 );
519 return $self->augment_results_with_meta("NAME", "VALUE", \%META, $RESULTS);
520}
521
522
# spent 5.55s (191µs+5.55) within Benchmark::Perl::Formance::run which was called: # once (191µs+5.55s) by main::RUNTIME at line 9 of bin/benchmark-perlformance
sub run {
5231700ns my ($self) = @_;
524
5251300ns my $help = 0;
5261100ns my $showconfig = 0;
5271500ns my $outstyle = "summary";
5281100ns my $platforminfo = 0;
5291200ns my $codespeed = 0;
5301200ns my $tapper = 0;
5311300ns my $cs_executable_suffix = "";
5321200ns my $cs_executable = "";
5331100ns my $cs_project = "";
5341200ns my $cs_branch = "";
5351200ns my $cs_commitid = "";
5361100ns my $cs_environment = "";
5371100ns my $verbose = 0;
5381100ns my $version = 0;
5391200ns my $fastmode = 0;
5401200ns my $useforks = 0;
5411200ns my $quiet = 0;
5421100ns my $stabilize_cpu = 0;
5431400ns my $plugins = $DEFAULT_PLUGINS;
5441200ns my $indent = $DEFAULT_INDENT;
5451200ns my $tapdescription = "";
5461400ns my $D = {};
547
548 # get options
54914µs16µs my $ok = GetOptions (
# spent 6µs making 1 call to Getopt::Long::GetOptions
550 "help|h" => \$help,
551 "quiet|q" => \$quiet,
552 "indent=i" => \$indent,
553 "plugins=s" => \$plugins,
554 "verbose|v+" => \$verbose,
555 "outstyle=s" => \$outstyle,
556 "fastmode" => \$fastmode,
557 "version" => \$version,
558 "useforks" => \$useforks,
559 "stabilize-cpu" => \$stabilize_cpu,
560 "showconfig|c+" => \$showconfig,
561 "platforminfo|p" => \$platforminfo,
562 "codespeed" => \$codespeed,
563 "tapper" => \$tapper,
564 "cs-executable-suffix=s" => \$cs_executable_suffix,
565 "cs-executable=s" => \$cs_executable,
566 "cs-project=s" => \$cs_project,
567 "cs-branch=s" => \$cs_branch,
568 "cs-commitid=s" => \$cs_commitid,
569 "cs-environment=s" => \$cs_environment,
570 "tapdescription=s" => \$tapdescription,
571 "D=s%" => \$D,
572 );
573 # fill options
57418µs $self->{options} = {
575 help => $help,
576 quiet => $quiet,
577 verbose => $verbose,
578 outstyle => $outstyle,
579 fastmode => $fastmode,
580 useforks => $useforks,
581 stabilize_cpu => $stabilize_cpu,
582 showconfig => $showconfig,
583 platforminfo => $platforminfo,
584 codespeed => $codespeed,
585 tapper => $tapper,
586 cs_executable_suffix => $cs_executable_suffix,
587 cs_executable => $cs_executable,
588 cs_project => $cs_project,
589 cs_branch => $cs_branch,
590 cs_commitid => $cs_commitid,
591 cs_environment => $cs_environment,
592 plugins => $plugins,
593 tapdescription => $tapdescription,
594 indent => $indent,
595 D => $D,
596 };
597
5981200ns do { $self->print_version; exit 0 } if $version;
5991100ns do { usage; exit 0 } if $help;
6001300ns do { usage; exit -1 } if not $ok;
601
602 # use forks if requested
6031200ns if ($useforks) {
604 eval "use forks"; ## no critic
605 $useforks = 0 if $@;
606 print STDERR "# use forks " . ($@ ? "failed" : "") . "\n" if $verbose;
607 }
608
609 # static list because dynamic require influences runtimes
6101400ns $plugins = $ALL_PLUGINS if $plugins eq "ALL";
611
612 # run plugins
613117µs112µs my $before = gettimeofday();
# spent 12µs making 1 call to Time::HiRes::gettimeofday
6141200ns my %RESULTS;
61518µs11µs my @plugins = grep /\w/, split '\s*,\s*', $plugins;
# spent 1µs making 1 call to Benchmark::Perl::Formance::CORE:match
616
61712µs13µs $self->prepare_stable_system;
# spent 3µs making 1 call to Benchmark::Perl::Formance::prepare_stable_system
61811µs foreach (@plugins)
619 {
620114µs23µs my @resultkeys = split(qr/::|\./, $_);
# spent 3µs making 1 call to Benchmark::Perl::Formance::CORE:qr # spent 400ns making 1 call to Benchmark::Perl::Formance::CORE:regcomp
62114µs15.54s my $res = $self->run_plugin($_);
# spent 5.54s making 1 call to Benchmark::Perl::Formance::run_plugin
622170µs eval "\$RESULTS{results}{".join("}{", @resultkeys)."} = \$res"; ## no critic
# spent 6µs executing statements in string eval
623 }
62416µs17µs $self->prepare_fast_system; # simply set to max, as restore_stable_system() is no reliable approach anyway
# spent 7µs making 1 call to Benchmark::Perl::Formance::prepare_fast_system
625
626111µs13µs my $after = gettimeofday();
# spent 3µs making 1 call to Time::HiRes::gettimeofday
62714µs $RESULTS{perlformance}{overall_runtime} = $after - $before;
62814µs $RESULTS{perlformance}{config}{fastmode} = $fastmode;
62911µs $RESULTS{perlformance}{config}{use_forks} = $useforks;
630
631 # Perl Config
6321300ns if ($showconfig)
633 {
634 # Config
635 my @cfgkeys;
636 push @cfgkeys, @{$CONFIG_KEYS{$_}} foreach 1..$showconfig;
637 $RESULTS{perl_config} =
638 {
639 map { $_ => $Config{$_} } sort @cfgkeys
640 };
641
642 # Config::Perl::V
643 $RESULTS{perl_config_v} = Config::Perl::V::myconfig;
644 }
645
646 # Perl Config
6471400ns if ($platforminfo)
648 {
649 $RESULTS{platform_info} = { $self->_get_platforminfo };
650 }
651
652 # Codespeed data blocks
6531200ns if ($codespeed)
654 {
655 $RESULTS{codespeed} = $self->generate_codespeed_data(\%RESULTS);
656 }
657
658 # Tapper BenchmarkAnythingData blocks
6591400ns if ($tapper)
660 {
661 $RESULTS{BenchmarkAnythingData} = $self->generate_BenchmarkAnythingData_data(\%RESULTS);
662 }
663
66417µs153µs unbless (\%RESULTS);
# spent 53µs making 1 call to Data::Structure::Util::unbless
665112µs return \%RESULTS;
666}
667
668sub print_outstyle_yaml
669{
670 my ($self, $RESULTS) = @_;
671
672 my $output = '';
673 my $indent = $self->{options}{indent};
674 my $yw = new Data::YAML::Writer;
675 $yw->write($RESULTS, sub { $output .= shift()."\n" });
676 $output =~ s/^/" "x$indent/emsg; # indent
677
678 my $tapdescription = $self->{options}{tapdescription};
679 $output = "ok $tapdescription\n".$output if $tapdescription;
680 print $output;
681}
682
683sub print_outstyle_json
684{
685 my ($self, $RESULTS) = @_;
686
687 require JSON;
688 my $json = JSON->new->allow_nonref;
689 print $json->pretty->encode( $RESULTS );
690}
691
692sub find_interesting_result_paths
693
# spent 7.70ms (218µs+7.48) within Benchmark::Perl::Formance::find_interesting_result_paths which was called: # once (218µs+7.48ms) by Benchmark::Perl::Formance::print_outstyle_summary at line 719
{
6941900ns my ($self, $RESULTS) = @_;
695
6961800ns my @all_keys = ();
697
698114µs23.61ms my $benchmarks = dpathi($RESULTS)->isearch("//Benchmark");
# spent 2.29ms making 1 call to Data::DPath::__ANON__[Data/DPath.pm:47] # spent 1.32ms making 1 call to Data::DPath::Context::isearch
699
700114µs315µs while ($benchmarks->isnt_exhausted) {
# spent 12µs making 2 calls to Iterator::DESTROY, avg 6µs/call # spent 4µs making 1 call to Iterator::isnt_exhausted
7012500ns my @keys;
70224µs2969µs my $benchmark = $benchmarks->value;
# spent 969µs making 2 calls to Iterator::value, avg 484µs/call
70328µs2597µs my $ancestors = $benchmark->isearch ("/::ancestor");
# spent 597µs making 2 calls to Data::DPath::Context::isearch, avg 298µs/call
704
70525µs25µs while ($ancestors->isnt_exhausted) {
# spent 5µs making 2 calls to Iterator::isnt_exhausted, avg 3µs/call
7061043µs202.19ms my $key = $ancestors->value->first_point->{attrs}{key};
# spent 2.16ms making 10 calls to Iterator::value, avg 216µs/call # spent 29µs making 10 calls to Data::DPath::Context::first_point, avg 3µs/call
7071026µs1023µs push @keys, $key if defined $key;
# spent 23µs making 10 calls to Iterator::isnt_exhausted, avg 2µs/call
708 }
7092900ns pop @keys;
710215µs445µs push @all_keys, join(".", reverse @keys);
# spent 40µs making 2 calls to Iterator::DESTROY, avg 20µs/call # spent 5µs making 2 calls to Iterator::isnt_exhausted, avg 2µs/call
711 }
71212µs return @all_keys;
713}
714
715sub print_outstyle_summary
716
# spent 10.2ms (113µs+10.0) within Benchmark::Perl::Formance::print_outstyle_summary which was called: # once (113µs+10.0ms) by Benchmark::Perl::Formance::print_results at line 739
{
7171800ns my ($self, $RESULTS) = @_;
718
719112µs27.72ms my @run_plugins = $self->find_interesting_result_paths($RESULTS);
# spent 7.70ms making 1 call to Benchmark::Perl::Formance::find_interesting_result_paths # spent 20µs making 1 call to Iterator::DESTROY
720111µs12µs my $len = max map { length } @run_plugins;
# spent 2µs making 1 call to List::Util::max
721
722117µs14µs foreach (sort @run_plugins) {
# spent 4µs making 1 call to Benchmark::Perl::Formance::CORE:sort
7232179µs228µs
# spent 18µs (8+10) within Benchmark::Perl::Formance::BEGIN@723 which was called: # once (8µs+10µs) by main::BEGIN@5 at line 723
no strict 'refs'; ## no critic
# spent 18µs making 1 call to Benchmark::Perl::Formance::BEGIN@723 # spent 10µs making 1 call to strict::unimport
72427µs my @resultkeys = split(/\./);
725235µs42.29ms my ($res) = dpath("/results/".join("/", map { qq("$_") } @resultkeys)."/Benchmark/*[0]")->match($RESULTS);
# spent 1.65ms making 2 calls to Data::DPath::__ANON__[Data/DPath.pm:27], avg 824µs/call # spent 640µs making 2 calls to Data::DPath::Path::match, avg 320µs/call
726285µs251µs print sprintf("%-${len}s : %f\n", $_, ($res || 0));
# spent 51µs making 2 calls to Benchmark::Perl::Formance::CORE:print, avg 26µs/call
727 }
728}
729
730sub print_results
731
# spent 10.2ms (32µs+10.2) within Benchmark::Perl::Formance::print_results which was called: # once (32µs+10.2ms) by main::RUNTIME at line 10 of bin/benchmark-perlformance
{
73211µs my ($self, $RESULTS) = @_;
7331900ns return if $self->{options}{quiet};
734
73511µs my $outstyle = $self->{options}{outstyle};
736133µs317µs $outstyle = "summary" unless $outstyle =~ qr/^(summary|yaml|json)$/;
# spent 8µs making 1 call to Benchmark::Perl::Formance::CORE:qr # spent 7µs making 1 call to Benchmark::Perl::Formance::CORE:match # spent 3µs making 1 call to Benchmark::Perl::Formance::CORE:regcomp
73712µs my $sub = "print_outstyle_$outstyle";
738
739111µs110.2ms $self->$sub($RESULTS);
# spent 10.2ms making 1 call to Benchmark::Perl::Formance::print_outstyle_summary
740}
741
742116µs1;
743
744__END__
 
# spent 20µs within Benchmark::Perl::Formance::CORE:close which was called 2 times, avg 10µs/call: # once (11µs+0s) by Benchmark::Perl::Formance::run_plugin at line 291 # once (8µs+0s) by Benchmark::Perl::Formance::run_plugin at line 289
sub Benchmark::Perl::Formance::CORE:close; # opcode
# spent 8µs within Benchmark::Perl::Formance::CORE:match which was called 2 times, avg 4µs/call: # once (7µs+0s) by Benchmark::Perl::Formance::print_results at line 736 # once (1µs+0s) by Benchmark::Perl::Formance::run at line 615
sub Benchmark::Perl::Formance::CORE:match; # opcode
# spent 365µs within Benchmark::Perl::Formance::CORE:open which was called: # once (365µs+0s) by Benchmark::Perl::Formance::run_plugin at line 268
sub Benchmark::Perl::Formance::CORE:open; # opcode
# spent 51µs within Benchmark::Perl::Formance::CORE:print which was called 2 times, avg 26µs/call: # 2 times (51µs+0s) by Benchmark::Perl::Formance::print_outstyle_summary at line 726, avg 26µs/call
sub Benchmark::Perl::Formance::CORE:print; # opcode
# spent 10µs within Benchmark::Perl::Formance::CORE:qr which was called 2 times, avg 5µs/call: # once (8µs+0s) by Benchmark::Perl::Formance::print_results at line 736 # once (3µs+0s) by Benchmark::Perl::Formance::run at line 620
sub Benchmark::Perl::Formance::CORE:qr; # opcode
# spent 3µs within Benchmark::Perl::Formance::CORE:regcomp which was called 2 times, avg 2µs/call: # once (3µs+0s) by Benchmark::Perl::Formance::print_results at line 736 # once (400ns+0s) by Benchmark::Perl::Formance::run at line 620
sub Benchmark::Perl::Formance::CORE:regcomp; # opcode
# spent 65µs within Benchmark::Perl::Formance::CORE:sort which was called 2 times, avg 33µs/call: # once (62µs+0s) by main::BEGIN@5 at line 74 # once (4µs+0s) by Benchmark::Perl::Formance::print_outstyle_summary at line 722
sub Benchmark::Perl::Formance::CORE:sort; # opcode
# spent 1µs within Benchmark::Perl::Formance::CORE:subst which was called: # once (1µs+0s) by Benchmark::Perl::Formance::run_plugin at line 260
sub Benchmark::Perl::Formance::CORE:subst; # opcode