← Index
NYTProf Performance Profile   « line view »
For runner.pl
  Run on Thu Jul 3 15:14:19 2014
Reported on Thu Jul 3 15:16:35 2014

Filename/home/rjamet/Work/Code/sinalgo/runnerv3/Runner/IO.pm
StatementsExecuted 4241 statements in 33.4ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11123.8ms27.6msRunner::IO::::dump_averagesRunner::IO::dump_averages
1115.02ms16.0msRunner::IO::::BEGIN@47Runner::IO::BEGIN@47
5512.45ms2.45msRunner::IO::::CORE:sortRunner::IO::CORE:sort (opcode)
41821211.74ms1.74msRunner::IO::::CORE:printRunner::IO::CORE:print (opcode)
991209µs209µsRunner::IO::::CORE:openRunner::IO::CORE:open (opcode)
662171µs357µsRunner::IO::::tprintRunner::IO::tprint
111113µs1.76msRunner::IO::::dump_node_dataRunner::IO::dump_node_data
99197µs97µsRunner::IO::::CORE:closeRunner::IO::CORE:close (opcode)
11155µs139µsRunner::IO::::dump_globalsRunner::IO::dump_globals
11135µs144µsRunner::IO::::rprintRunner::IO::rprint
11134µs68µsRunner::IO::::BEGIN@3Runner::IO::BEGIN@3
11126µs189µsRunner::IO::::BEGIN@6Runner::IO::BEGIN@6
11119µs110µsRunner::IO::::BEGIN@5Runner::IO::BEGIN@5
11118µs35µsRunner::IO::::BEGIN@4Runner::IO::BEGIN@4
11114µs14µsRunner::IO::::BEGIN@12Runner::IO::BEGIN@12
0000s0sRunner::IO::::dump_jsonRunner::IO::dump_json
0000s0sRunner::IO::::dump_rawRunner::IO::dump_raw
0000s0sRunner::IO::::runner_usageRunner::IO::runner_usage
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Runner::IO;
2
3265µs2101µs
# spent 68µs (34+33) within Runner::IO::BEGIN@3 which was called: # once (34µs+33µs) by Runner::BEGIN@15 at line 3
use strict;
# spent 68µs making 1 call to Runner::IO::BEGIN@3 # spent 33µs making 1 call to strict::import
4258µs252µs
# spent 35µs (18+17) within Runner::IO::BEGIN@4 which was called: # once (18µs+17µs) by Runner::BEGIN@15 at line 4
use warnings;
# spent 35µs making 1 call to Runner::IO::BEGIN@4 # spent 17µs making 1 call to warnings::import
5283µs2202µs
# spent 110µs (19+92) within Runner::IO::BEGIN@5 which was called: # once (19µs+92µs) by Runner::BEGIN@15 at line 5
use Carp;
# spent 110µs making 1 call to Runner::IO::BEGIN@5 # spent 92µs making 1 call to Exporter::import
6293µs2206µs
# spent 189µs (26+163) within Runner::IO::BEGIN@6 which was called: # once (26µs+163µs) by Runner::BEGIN@15 at line 6
use List::Util qq/sum/;
# spent 189µs making 1 call to Runner::IO::BEGIN@6 # spent 18µs making 1 call to List::Util::import
7
8#use File::Map qw(map_file);
9
101400nsmy $tbegin;
11
12
# spent 14µs within Runner::IO::BEGIN@12 which was called: # once (14µs+0s) by Runner::BEGIN@15 at line 14
BEGIN{
13114µs $tbegin = time();
141458µs114µs}
# spent 14µs making 1 call to Runner::IO::BEGIN@12
15
16
17sub runner_usage {
18 print "Third iteration of the sinalgo simulation runner\n";
19 print "Runs some sinalgo simulations, JSON magic, basic computations,".
20 " gnuplot scripts, and a lot of small other things.\n\n";
21
22 print "Usage : ./runner.pl \n".
23 " -p Project_to_run \n".
24 " -n Name_of_the_run \n".
25 " -N Node creation command (\"-gen 10 TLCN:TLCNNode Random\")\n".
26 " [-a \"some/Sinalgo/XML=attributes With/some=quotes\"]\n".
27 " [-r Number_of_simulation_runs]\n".
28# " [-d \"Spaced list of destination machines\" (defaults to localhost)]\n". NEVER IMPLEMENTED
29 " You can also use \$RUN in the params, which will be replaced by the good value.\n";
30
31}
32
33
# spent 144µs (35+109) within Runner::IO::rprint which was called: # once (35µs+109µs) by main::RUNTIME at line 45 of runner.pl
sub rprint {
34167µs152µs print "\033[33m";
# spent 52µs making 1 call to Runner::IO::CORE:print
3514µs146µs tprint(@_);
# spent 46µs making 1 call to Runner::IO::tprint
36127µs111µs print "\033[0m";
# spent 11µs making 1 call to Runner::IO::CORE:print
37}
38
39
# spent 357µs (171+186) within Runner::IO::tprint which was called 6 times, avg 60µs/call: # once (44µs+48µs) by main::RUNTIME at line 65 of runner.pl # once (34µs+37µs) by main::RUNTIME at line 157 of runner.pl # once (22µs+31µs) by main::RUNTIME at line 59 of runner.pl # once (19µs+34µs) by main::RUNTIME at line 55 of runner.pl # once (28µs+19µs) by Runner::IO::rprint at line 35 # once (23µs+17µs) by main::RUNTIME at line 46 of runner.pl
sub tprint {
40613µs my $tstring = time() - $tbegin;
41634µs $tstring = ' 'x(10-length($tstring)) . $tstring;
426333µs6186µs print "[".$tstring."] ".join (" ",@_);
# spent 186µs making 6 calls to Runner::IO::CORE:print, avg 31µs/call
43}
44
45
46#avoid cyclic dependancies
4722.64ms116.0ms
# spent 16.0ms (5.02+11.0) within Runner::IO::BEGIN@47 which was called: # once (5.02ms+11.0ms) by Runner::BEGIN@15 at line 47
use Runner::Stats;
# spent 16.0ms making 1 call to Runner::IO::BEGIN@47
48
49
# spent 27.6ms (23.8+3.80) within Runner::IO::dump_averages which was called: # once (23.8ms+3.80ms) by main::RUNTIME at line 147 of runner.pl
sub dump_averages($$) {
5013µs my $data = shift;
5111µs my $name = shift;
52
53
- -
56169µs135µs open(my $average_on_tb, "> ../results/$name/av_tb.data")
# spent 35µs making 1 call to Runner::IO::CORE:open
57 or croak("Can't open the file ! $!");
581809µs1789µs foreach (sort {$a->{t} <=> $b->{t}} @{$data->{average_rolling}}) {
# spent 789µs making 1 call to Runner::IO::CORE:sort
598006.52ms800346µs print $average_on_tb ($_->{t}." ".$_->{h}." ".$_->{o}."\n");
# spent 346µs making 800 calls to Runner::IO::CORE:print, avg 432ns/call
60 }
61126µs116µs close($average_on_tb);
# spent 16µs making 1 call to Runner::IO::CORE:close
62
63
64146µs136µs open(my $average_on_tb_ack, "> ../results/$name/av_tb_ack.data")
# spent 36µs making 1 call to Runner::IO::CORE:open
65 or croak("Can't open the file ! $!");
661489µs1480µs foreach (sort {$a->{t} <=> $b->{t}} @{$data->{average_rolling_ack}}) {
# spent 480µs making 1 call to Runner::IO::CORE:sort
677703.00ms770176µs print $average_on_tb_ack ($_->{t}." ".$_->{h}."\n");
# spent 176µs making 770 calls to Runner::IO::CORE:print, avg 228ns/call
68 }
69117µs113µs close($average_on_tb_ack);
# spent 13µs making 1 call to Runner::IO::CORE:close
70
71
72129µs120µs open(my $tph, "> ../results/$name/tph.data")
# spent 20µs making 1 call to Runner::IO::CORE:open
73 or croak("Can't open the file ! $!");
741312µs1305µs foreach (sort {$a->{t} <=> $b->{t}} @{$data->{average_rolling}}) {
# spent 305µs making 1 call to Runner::IO::CORE:sort
758002.22ms800192µs print $tph ($_->{t}." ".$_->{tph}."\n");
# spent 192µs making 800 calls to Runner::IO::CORE:print, avg 240ns/call
76 }
77112µs18µs close($tph);
# spent 8µs making 1 call to Runner::IO::CORE:close
78
79# open(my $en, "> ../results/$name/energy.data")
80# or croak("Can't open the file ! $!");
81# foreach (sort {$a->{tb} <=> $b->{tb}} @{$data->{energy_rolling}}) {
82# print $en ($_->{tb}." ".$_->{te}." ".$_->{nbh}." ".$_->{cnbh}." ".$_->{pnbh}." ".$_->{cpnbh}."\n");
83# }
84# close($en);
85
86128µs118µs open(my $delivery_on_tb, "> ../results/$name/de_tb.data")
# spent 18µs making 1 call to Runner::IO::CORE:open
87 or croak("Can't open the file ! $!");
881502µs1492µs foreach (sort {$a->{t} <=> $b->{t}} @{$data->{delivery_rolling}}) {
# spent 492µs making 1 call to Runner::IO::CORE:sort
8910005.44ms1000227µs print $delivery_on_tb ($_->{t}." ".$_->{ok}." ".($_->{eaten}+$_->{ok})." ".(($_->{eaten}) + ($_->{ok}) + ($_->{ttl}))."\n");
# spent 227µs making 1000 calls to Runner::IO::CORE:print, avg 227ns/call
90 }
91119µs114µs close($delivery_on_tb);
# spent 14µs making 1 call to Runner::IO::CORE:close
92
- -
95134µs124µs open(my $delivery_on_tb_ack, "> ../results/$name/de_tb_ack.data")
# spent 24µs making 1 call to Runner::IO::CORE:open
96 or croak("Can't open the file ! $!");
971393µs1385µs foreach (sort {$a->{t} <=> $b->{t}} @{$data->{delivery_rolling_ack}}) {
# spent 385µs making 1 call to Runner::IO::CORE:sort
988007.54ms800209µs print $delivery_on_tb_ack (
# spent 209µs making 800 calls to Runner::IO::CORE:print, avg 261ns/call
99 $_->{t}." ".
100 $_->{ok}." ".
101 ($_->{ok} + $_->{for})." ".
102 ($_->{eaten}+$_->{ok}+$_->{for})." ".
103 (($_->{eaten}) + ($_->{ok}) + ($_->{ttl}) + $_->{for})."\n");
104 }
105117µs111µs close($delivery_on_tb_ack);
# spent 11µs making 1 call to Runner::IO::CORE:close
106
107
108128µs return 1;
109}
110
111sub dump_raw($$) {
112 my $data = shift;
113 my $name = shift;
114 open(my $raw_points, "> ../results/$name/raw.data");
115 print $raw_points $_->{tb}." ".$_->{h}."\n" foreach (grep {$_->{type} eq "basic"} @{$data->{msg_data}});
116 close($raw_points);
117 return 1;
118}
119
120sub dump_json {
121 my $data = shift;
122 my $name = shift;
123 my $tmp = $data->{msg_data};
124 $data->{msg_data}=[];
125 if (open (my $fout,"> ../results/$name/dump.json")) {
126 print $fout JSON::XS->new->pretty->shrink->encode($data);
127 close($fout);
128 $data->{msg_data}=$tmp;
129 return 1;
130 } else {
131 $data->{msg_data}=$tmp;
132
133 carp "Couldn't open \"../results/$name/dump.json\" : $!";
134 return 0;
135 }
136}
137
138
# spent 139µs (55+84) within Runner::IO::dump_globals which was called: # once (55µs+84µs) by main::RUNTIME at line 148 of runner.pl
sub dump_globals {
1391800ns my $data = shift;
1401500ns my $name = shift;
141
142138µs129µs open(my $glob, "> ../results/$name/glob.json");
# spent 29µs making 1 call to Runner::IO::CORE:open
143179µs444µs print $glob JSON::XS->new->pretty->encode($data->{simulation});
# spent 33µs making 1 call to JSON::XS::encode # spent 6µs making 1 call to Runner::IO::CORE:print # spent 4µs making 1 call to JSON::XS::new # spent 1µs making 1 call to JSON::XS::pretty
144114µs211µs close $glob;
# spent 10µs making 1 call to Runner::IO::CORE:close # spent 1µs making 1 call to JSON::XS::DESTROY
14515µs return 0;
146
147}
148
149
# spent 1.76ms (113µs+1.65) within Runner::IO::dump_node_data which was called: # once (113µs+1.65ms) by main::RUNTIME at line 149 of runner.pl
sub dump_node_data{
15011µs my $data = shift;
1511500ns my $name = shift;
152122µs115µs open(my $glob, "> ../results/$name/node_data.json");
# spent 15µs making 1 call to Runner::IO::CORE:open
15311.59ms41.56ms print $glob JSON::XS->new->pretty->encode($data->{nodes});
# spent 1.23ms making 1 call to JSON::XS::encode # spent 334µs making 1 call to Runner::IO::CORE:print # spent 1µs making 1 call to JSON::XS::new # spent 500ns making 1 call to JSON::XS::pretty
154114µs211µs close $glob;
# spent 9µs making 1 call to Runner::IO::CORE:close # spent 2µs making 1 call to JSON::XS::DESTROY
155
15613µs if ($data->{simulation}->{nothing_delivered} != 1) {
157
158124µs119µs open ($glob, "> ../results/$name/classes.data");
# spent 19µs making 1 call to Runner::IO::CORE:open
159145µs66µs print $glob $name." ".join (" ", map { $_ / (sum @{$data->{simulation}->{classes}}) } @{$data->{simulation}->{classes}});
# spent 4µs making 5 calls to List::Util::sum, avg 900ns/call # spent 1µs making 1 call to Runner::IO::CORE:print
160113µs19µs close $glob;
# spent 9µs making 1 call to Runner::IO::CORE:close
161
162119µs112µs open ($glob, "> ../results/$name/moustache.data");
# spent 12µs making 1 call to Runner::IO::CORE:open
163110µs11µs print $glob $name." ".join (" ",@{$data->{simulation}->{boxplot}});
# spent 1µs making 1 call to Runner::IO::CORE:print
164112µs18µs close $glob;
# spent 8µs making 1 call to Runner::IO::CORE:close
165 }
16617µs return 0;
167
168
169}
170
171#sub import_json { #Untested yet
172# my $filename = shift;
173# map_file my $data, $filename;
174# advise $data, "sequential";
175# return JSON::XS->new->decode($data);
176#}
177
17818µsreturn 1;
 
# spent 97µs within Runner::IO::CORE:close which was called 9 times, avg 11µs/call: # once (16µs+0s) by Runner::IO::dump_averages at line 61 # once (14µs+0s) by Runner::IO::dump_averages at line 91 # once (13µs+0s) by Runner::IO::dump_averages at line 69 # once (11µs+0s) by Runner::IO::dump_averages at line 105 # once (10µs+0s) by Runner::IO::dump_globals at line 144 # once (9µs+0s) by Runner::IO::dump_node_data at line 160 # once (9µs+0s) by Runner::IO::dump_node_data at line 154 # once (8µs+0s) by Runner::IO::dump_node_data at line 164 # once (8µs+0s) by Runner::IO::dump_averages at line 77
sub Runner::IO::CORE:close; # opcode
# spent 209µs within Runner::IO::CORE:open which was called 9 times, avg 23µs/call: # once (36µs+0s) by Runner::IO::dump_averages at line 64 # once (35µs+0s) by Runner::IO::dump_averages at line 56 # once (29µs+0s) by Runner::IO::dump_globals at line 142 # once (24µs+0s) by Runner::IO::dump_averages at line 95 # once (20µs+0s) by Runner::IO::dump_averages at line 72 # once (19µs+0s) by Runner::IO::dump_node_data at line 158 # once (18µs+0s) by Runner::IO::dump_averages at line 86 # once (15µs+0s) by Runner::IO::dump_node_data at line 152 # once (12µs+0s) by Runner::IO::dump_node_data at line 162
sub Runner::IO::CORE:open; # opcode
# spent 1.74ms within Runner::IO::CORE:print which was called 4182 times, avg 416ns/call: # 1000 times (227µs+0s) by Runner::IO::dump_averages at line 89, avg 227ns/call # 800 times (346µs+0s) by Runner::IO::dump_averages at line 59, avg 432ns/call # 800 times (209µs+0s) by Runner::IO::dump_averages at line 98, avg 261ns/call # 800 times (192µs+0s) by Runner::IO::dump_averages at line 75, avg 240ns/call # 770 times (176µs+0s) by Runner::IO::dump_averages at line 67, avg 228ns/call # 6 times (186µs+0s) by Runner::IO::tprint at line 42, avg 31µs/call # once (334µs+0s) by Runner::IO::dump_node_data at line 153 # once (52µs+0s) by Runner::IO::rprint at line 34 # once (11µs+0s) by Runner::IO::rprint at line 36 # once (6µs+0s) by Runner::IO::dump_globals at line 143 # once (1µs+0s) by Runner::IO::dump_node_data at line 159 # once (1µs+0s) by Runner::IO::dump_node_data at line 163
sub Runner::IO::CORE:print; # opcode
# spent 2.45ms within Runner::IO::CORE:sort which was called 5 times, avg 490µs/call: # once (789µs+0s) by Runner::IO::dump_averages at line 58 # once (492µs+0s) by Runner::IO::dump_averages at line 88 # once (480µs+0s) by Runner::IO::dump_averages at line 66 # once (385µs+0s) by Runner::IO::dump_averages at line 97 # once (305µs+0s) by Runner::IO::dump_averages at line 74
sub Runner::IO::CORE:sort; # opcode