Filename | /home/rjamet/Work/Code/sinalgo/runnerv3/Runner/IO.pm |
Statements | Executed 4241 statements in 33.4ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 23.8ms | 27.6ms | dump_averages | Runner::IO::
1 | 1 | 1 | 5.02ms | 16.0ms | BEGIN@47 | Runner::IO::
5 | 5 | 1 | 2.45ms | 2.45ms | CORE:sort (opcode) | Runner::IO::
4182 | 12 | 1 | 1.74ms | 1.74ms | CORE:print (opcode) | Runner::IO::
9 | 9 | 1 | 209µs | 209µs | CORE:open (opcode) | Runner::IO::
6 | 6 | 2 | 171µs | 357µs | tprint | Runner::IO::
1 | 1 | 1 | 113µs | 1.76ms | dump_node_data | Runner::IO::
9 | 9 | 1 | 97µs | 97µs | CORE:close (opcode) | Runner::IO::
1 | 1 | 1 | 55µs | 139µs | dump_globals | Runner::IO::
1 | 1 | 1 | 35µs | 144µs | rprint | Runner::IO::
1 | 1 | 1 | 34µs | 68µs | BEGIN@3 | Runner::IO::
1 | 1 | 1 | 26µs | 189µs | BEGIN@6 | Runner::IO::
1 | 1 | 1 | 19µs | 110µs | BEGIN@5 | Runner::IO::
1 | 1 | 1 | 18µs | 35µs | BEGIN@4 | Runner::IO::
1 | 1 | 1 | 14µs | 14µs | BEGIN@12 | Runner::IO::
0 | 0 | 0 | 0s | 0s | dump_json | Runner::IO::
0 | 0 | 0 | 0s | 0s | dump_raw | Runner::IO::
0 | 0 | 0 | 0s | 0s | runner_usage | Runner::IO::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Runner::IO; | ||||
2 | |||||
3 | 2 | 65µs | 2 | 101µ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 # spent 68µs making 1 call to Runner::IO::BEGIN@3
# spent 33µs making 1 call to strict::import |
4 | 2 | 58µs | 2 | 52µ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 # spent 35µs making 1 call to Runner::IO::BEGIN@4
# spent 17µs making 1 call to warnings::import |
5 | 2 | 83µs | 2 | 202µ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 # spent 110µs making 1 call to Runner::IO::BEGIN@5
# spent 92µs making 1 call to Exporter::import |
6 | 2 | 93µs | 2 | 206µ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 # 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 | |||||
10 | 1 | 400ns | my $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 | ||||
13 | 1 | 14µs | $tbegin = time(); | ||
14 | 1 | 458µs | 1 | 14µs | } # spent 14µs making 1 call to Runner::IO::BEGIN@12 |
15 | |||||
16 | |||||
17 | sub 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 | ||||
34 | 1 | 67µs | 1 | 52µs | print "\033[33m"; # spent 52µs making 1 call to Runner::IO::CORE:print |
35 | 1 | 4µs | 1 | 46µs | tprint(@_); # spent 46µs making 1 call to Runner::IO::tprint |
36 | 1 | 27µs | 1 | 11µ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 | ||||
40 | 6 | 13µs | my $tstring = time() - $tbegin; | ||
41 | 6 | 34µs | $tstring = ' 'x(10-length($tstring)) . $tstring; | ||
42 | 6 | 333µs | 6 | 186µ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 | ||||
47 | 2 | 2.64ms | 1 | 16.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 # 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 | ||||
50 | 1 | 3µs | my $data = shift; | ||
51 | 1 | 1µs | my $name = shift; | ||
52 | |||||
53 | |||||
- - | |||||
56 | 1 | 69µs | 1 | 35µ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 ! $!"); | ||||
58 | 1 | 809µs | 1 | 789µs | foreach (sort {$a->{t} <=> $b->{t}} @{$data->{average_rolling}}) { # spent 789µs making 1 call to Runner::IO::CORE:sort |
59 | 800 | 6.52ms | 800 | 346µs | print $average_on_tb ($_->{t}." ".$_->{h}." ".$_->{o}."\n"); # spent 346µs making 800 calls to Runner::IO::CORE:print, avg 432ns/call |
60 | } | ||||
61 | 1 | 26µs | 1 | 16µs | close($average_on_tb); # spent 16µs making 1 call to Runner::IO::CORE:close |
62 | |||||
63 | |||||
64 | 1 | 46µs | 1 | 36µ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 ! $!"); | ||||
66 | 1 | 489µs | 1 | 480µs | foreach (sort {$a->{t} <=> $b->{t}} @{$data->{average_rolling_ack}}) { # spent 480µs making 1 call to Runner::IO::CORE:sort |
67 | 770 | 3.00ms | 770 | 176µs | print $average_on_tb_ack ($_->{t}." ".$_->{h}."\n"); # spent 176µs making 770 calls to Runner::IO::CORE:print, avg 228ns/call |
68 | } | ||||
69 | 1 | 17µs | 1 | 13µs | close($average_on_tb_ack); # spent 13µs making 1 call to Runner::IO::CORE:close |
70 | |||||
71 | |||||
72 | 1 | 29µs | 1 | 20µ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 ! $!"); | ||||
74 | 1 | 312µs | 1 | 305µs | foreach (sort {$a->{t} <=> $b->{t}} @{$data->{average_rolling}}) { # spent 305µs making 1 call to Runner::IO::CORE:sort |
75 | 800 | 2.22ms | 800 | 192µs | print $tph ($_->{t}." ".$_->{tph}."\n"); # spent 192µs making 800 calls to Runner::IO::CORE:print, avg 240ns/call |
76 | } | ||||
77 | 1 | 12µs | 1 | 8µ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 | |||||
86 | 1 | 28µs | 1 | 18µ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 ! $!"); | ||||
88 | 1 | 502µs | 1 | 492µs | foreach (sort {$a->{t} <=> $b->{t}} @{$data->{delivery_rolling}}) { # spent 492µs making 1 call to Runner::IO::CORE:sort |
89 | 1000 | 5.44ms | 1000 | 227µ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 | } | ||||
91 | 1 | 19µs | 1 | 14µs | close($delivery_on_tb); # spent 14µs making 1 call to Runner::IO::CORE:close |
92 | |||||
- - | |||||
95 | 1 | 34µs | 1 | 24µ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 ! $!"); | ||||
97 | 1 | 393µs | 1 | 385µs | foreach (sort {$a->{t} <=> $b->{t}} @{$data->{delivery_rolling_ack}}) { # spent 385µs making 1 call to Runner::IO::CORE:sort |
98 | 800 | 7.54ms | 800 | 209µ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 | } | ||||
105 | 1 | 17µs | 1 | 11µs | close($delivery_on_tb_ack); # spent 11µs making 1 call to Runner::IO::CORE:close |
106 | |||||
107 | |||||
108 | 1 | 28µs | return 1; | ||
109 | } | ||||
110 | |||||
111 | sub 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 | |||||
120 | sub 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 | ||||
139 | 1 | 800ns | my $data = shift; | ||
140 | 1 | 500ns | my $name = shift; | ||
141 | |||||
142 | 1 | 38µs | 1 | 29µs | open(my $glob, "> ../results/$name/glob.json"); # spent 29µs making 1 call to Runner::IO::CORE:open |
143 | 1 | 79µs | 4 | 44µ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 |
144 | 1 | 14µs | 2 | 11µs | close $glob; # spent 10µs making 1 call to Runner::IO::CORE:close
# spent 1µs making 1 call to JSON::XS::DESTROY |
145 | 1 | 5µ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 | ||||
150 | 1 | 1µs | my $data = shift; | ||
151 | 1 | 500ns | my $name = shift; | ||
152 | 1 | 22µs | 1 | 15µs | open(my $glob, "> ../results/$name/node_data.json"); # spent 15µs making 1 call to Runner::IO::CORE:open |
153 | 1 | 1.59ms | 4 | 1.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 |
154 | 1 | 14µs | 2 | 11µ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 | |||||
156 | 1 | 3µs | if ($data->{simulation}->{nothing_delivered} != 1) { | ||
157 | |||||
158 | 1 | 24µs | 1 | 19µs | open ($glob, "> ../results/$name/classes.data"); # spent 19µs making 1 call to Runner::IO::CORE:open |
159 | 1 | 45µs | 6 | 6µ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 |
160 | 1 | 13µs | 1 | 9µs | close $glob; # spent 9µs making 1 call to Runner::IO::CORE:close |
161 | |||||
162 | 1 | 19µs | 1 | 12µs | open ($glob, "> ../results/$name/moustache.data"); # spent 12µs making 1 call to Runner::IO::CORE:open |
163 | 1 | 10µs | 1 | 1µs | print $glob $name." ".join (" ",@{$data->{simulation}->{boxplot}}); # spent 1µs making 1 call to Runner::IO::CORE:print |
164 | 1 | 12µs | 1 | 8µs | close $glob; # spent 8µs making 1 call to Runner::IO::CORE:close |
165 | } | ||||
166 | 1 | 7µ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 | |||||
178 | 1 | 8µs | return 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 | |||||
# 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 | |||||
# 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 | |||||
# 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 |