Filename | /home/rjamet/Work/Code/sinalgo/runnerv3/runner.pl |
Statements | Executed 4727369 statements in 99.9s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1180650 | 5 | 1 | 87.4s | 87.4s | CORE:readline (opcode) | Runner::
1180789 | 5 | 1 | 1.06s | 1.06s | CORE:match (opcode) | Runner::
1 | 1 | 1 | 14.6ms | 33.3ms | BEGIN@12 | Runner::
1 | 1 | 1 | 7.74ms | 7.87ms | BEGIN@8 | Runner::
1 | 1 | 1 | 6.50ms | 6.63ms | BEGIN@10 | Runner::
1 | 1 | 1 | 6.36ms | 6.36ms | CORE:backtick (opcode) | Runner::
1 | 1 | 1 | 4.21ms | 18.1ms | BEGIN@11 | Runner::
1 | 1 | 1 | 3.56ms | 20.0ms | BEGIN@15 | Runner::
1 | 1 | 1 | 1.38ms | 1.50ms | BEGIN@17 | Runner::
1 | 1 | 1 | 1.02ms | 1.14ms | BEGIN@9 | Runner::
1 | 1 | 1 | 859µs | 1.49ms | BEGIN@14 | Runner::
1 | 1 | 1 | 97µs | 97µs | CORE:close (opcode) | Runner::
2 | 2 | 1 | 80µs | 80µs | CORE:mkdir (opcode) | Runner::
1 | 1 | 1 | 20µs | 141µs | BEGIN@13 | Runner::
1 | 1 | 1 | 18µs | 18µs | can (xsub) | UNIVERSAL::
1 | 1 | 1 | 14µs | 14µs | BEGIN@16 | Runner::
1 | 1 | 1 | 14µs | 14µs | (bool (xsub) | version::
1 | 1 | 1 | 13µs | 13µs | (cmp (xsub) | version::
1 | 1 | 1 | 10µs | 10µs | SvREADONLY (xsub) | Internals::
1 | 1 | 1 | 5µs | 5µs | method_changed_in (xsub) | mro::
0 | 0 | 0 | 0s | 0s | BEGIN (xsub) | main::
0 | 0 | 0 | 0s | 0s | RUNTIME | main::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | #!/usr/bin/perl | ||||
2 | # rjamet, jan 2012 | ||||
3 | # Runs a sinalgo session, JSONify the output, decode it, | ||||
4 | # compute some small things, spit out results, and graphs it | ||||
5 | |||||
6 | package Runner; | ||||
7 | |||||
8 | 2 | 7.37ms | 2 | 7.89ms | # spent 7.87ms (7.74+128µs) within Runner::BEGIN@8 which was called:
# once (7.74ms+128µs) by main::RUNTIME at line 8 # spent 7.87ms making 1 call to Runner::BEGIN@8
# spent 28µs making 1 call to warnings::import |
9 | 2 | 1.02ms | 2 | 1.20ms | # spent 1.14ms (1.02+118µs) within Runner::BEGIN@9 which was called:
# once (1.02ms+118µs) by main::RUNTIME at line 9 # spent 1.14ms making 1 call to Runner::BEGIN@9
# spent 60µs making 1 call to strict::import |
10 | 2 | 4.51ms | 2 | 6.76ms | # spent 6.63ms (6.50+130µs) within Runner::BEGIN@10 which was called:
# once (6.50ms+130µs) by main::RUNTIME at line 10 # spent 6.63ms making 1 call to Runner::BEGIN@10
# spent 130µs making 1 call to Exporter::import |
11 | 2 | 972µs | 2 | 18.2ms | # spent 18.1ms (4.21+13.9) within Runner::BEGIN@11 which was called:
# once (4.21ms+13.9ms) by main::RUNTIME at line 11 # spent 18.1ms making 1 call to Runner::BEGIN@11
# spent 125µs making 1 call to Exporter::import |
12 | 2 | 1.11ms | 2 | 33.4ms | # spent 33.3ms (14.6+18.7) within Runner::BEGIN@12 which was called:
# once (14.6ms+18.7ms) by main::RUNTIME at line 12 # spent 33.3ms making 1 call to Runner::BEGIN@12
# spent 122µs making 1 call to Exporter::import |
13 | 2 | 68µs | 2 | 261µs | # spent 141µs (20+120) within Runner::BEGIN@13 which was called:
# once (20µs+120µs) by main::RUNTIME at line 13 # spent 141µs making 1 call to Runner::BEGIN@13
# spent 120µs making 1 call to Exporter::import |
14 | 2 | 229µs | 2 | 1.51ms | # spent 1.49ms (859µs+628µs) within Runner::BEGIN@14 which was called:
# once (859µs+628µs) by main::RUNTIME at line 14 # spent 1.49ms making 1 call to Runner::BEGIN@14
# spent 21µs making 1 call to List::Util::import |
15 | 2 | 750µs | 1 | 20.0ms | # spent 20.0ms (3.56+16.4) within Runner::BEGIN@15 which was called:
# once (3.56ms+16.4ms) by main::RUNTIME at line 15 # spent 20.0ms making 1 call to Runner::BEGIN@15 |
16 | 2 | 75µs | 1 | 14µs | # spent 14µs within Runner::BEGIN@16 which was called:
# once (14µs+0s) by main::RUNTIME at line 16 # spent 14µs making 1 call to Runner::BEGIN@16 |
17 | 2 | 2.49ms | 1 | 1.50ms | # spent 1.50ms (1.38+123µs) within Runner::BEGIN@17 which was called:
# once (1.38ms+123µs) by main::RUNTIME at line 17 # spent 1.50ms making 1 call to Runner::BEGIN@17 |
18 | |||||
19 | |||||
20 | 1 | 4µs | $| = 1; | ||
21 | 1 | 600ns | $Getopt::Std::STANDARD_HELP_VERSION = 1; | ||
22 | |||||
23 | # Parse the cmdline arguments | ||||
24 | 1 | 600ns | my %opts; | ||
25 | 1 | 8µs | 1 | 170µs | getopt('Nnpard',\%opts); #$opts->{a} is the args # spent 170µs making 1 call to Getopt::Std::getopt |
26 | |||||
27 | 1 | 2µs | if (!defined($opts{N}) || !defined($opts{n}) || !defined($opts{p})) { | ||
28 | Runner::IO::runner_usage(); | ||||
29 | exit(1); | ||||
30 | } | ||||
31 | |||||
32 | |||||
33 | 1 | 400ns | my @destinations; | ||
34 | 1 | 700ns | if (defined($opts{d})) { | ||
35 | @destinations = split(/ /, $opts{d}); | ||||
36 | } | ||||
37 | |||||
38 | 1 | 1µs | my $tbegin = time; | ||
39 | 1 | 20µs | my ($name, $project) = ($opts{n},$opts{p}); | ||
40 | |||||
41 | |||||
42 | 1 | 700ns | my $nbmsg = 100; | ||
43 | 1 | 2µs | my $nbruns = defined($opts{r}) ? $opts{r} : 10; | ||
44 | |||||
45 | 1 | 8µs | 1 | 144µs | Runner::IO::rprint "###### Runner launching campaign ".$opts{n}." \n"; # spent 144µs making 1 call to Runner::IO::rprint |
46 | 1 | 4µs | 1 | 40µs | Runner::IO::tprint "### Running Sinalgo... \n"; # spent 40µs making 1 call to Runner::IO::tprint |
47 | |||||
48 | 1 | 9µs | my $sinalgo_command = "cd .. && ./sinalgo". | ||
49 | " -batch -project ${project} ".$opts{N}." -overwrite ".$opts{a}; | ||||
50 | |||||
51 | #print $sinalgo_command."\n"; | ||||
52 | |||||
53 | 1 | 47µs | 1 | 35µs | mkdir ("../results"); # spent 35µs making 1 call to Runner::CORE:mkdir |
54 | |||||
55 | 1 | 8µs | 1 | 53µs | Runner::IO::tprint "### Command : $sinalgo_command\n"; # spent 53µs making 1 call to Runner::IO::tprint |
56 | |||||
57 | 1 | 7µs | for my $run (0..$nbruns-1) { ###Running simulations... done ! | ||
58 | |||||
59 | 1 | 11µs | 1 | 54µs | Runner::IO::tprint "###### Computing for run $run / $nbruns of ".$opts{n}." command ".$sinalgo_command."\n"; # spent 54µs making 1 call to Runner::IO::tprint |
60 | |||||
61 | 1 | 3µs | my $run_name = $name."_".$run; | ||
62 | |||||
63 | 1 | 7µs | 1 | 1.46ms | my $jhandle = Runner::Job::getJobHandle($sinalgo_command, $run); # spent 1.46ms making 1 call to Runner::Job::getJobHandle |
64 | |||||
65 | 1 | 16µs | 1 | 93µs | Runner::IO::tprint "### Un-JSONify the results\n"; # spent 93µs making 1 call to Runner::IO::tprint |
66 | 1 | 3µs | my $data = {}; | ||
67 | 1 | 900ns | my $mode = -1; # -1 for pre-simulation sinalgo crap | ||
68 | |||||
69 | 1 | 765ms | 141 | 764ms | THIS_SIMULATION: while (<$jhandle>) { #Reading from STDIN # spent 764ms making 141 calls to Runner::CORE:readline, avg 5.42ms/call |
70 | 142 | 938µs | 142 | 510µs | /^.+$/ or next(); #Ensure we read something more than a \n # spent 510µs making 142 calls to Runner::CORE:match, avg 4µs/call |
71 | |||||
72 | 139 | 74µs | if ($mode == -1) { | ||
73 | 137 | 471µs | 137 | 149µs | if (/Starting the Simulation\./) { # spent 149µs making 137 calls to Runner::CORE:match, avg 1µs/call |
74 | $mode = 0; #Switch once we find the right flag | ||||
75 | } | ||||
76 | 137 | 105µs | next; | ||
77 | } | ||||
78 | |||||
79 | 2 | 35µs | 4 | 79µs | if (/^===BEGIN MESSAGE DATA===$/) { # spent 64µs making 1 call to JSON::XS::DESTROY
# spent 12µs making 1 call to Runner::CORE:readline
# spent 3µs making 2 calls to Runner::CORE:match, avg 2µs/call |
80 | 1 | 55µs | 3 | 17µs | my $json = JSON::XS->new->relaxed->shrink; # spent 16µs making 1 call to JSON::XS::new
# spent 1µs making 1 call to JSON::XS::relaxed
# spent 700ns making 1 call to JSON::XS::shrink |
81 | 1 | 5µs | $data->{msg_data} = []; | ||
82 | 1 | 2µs | my @todecode = (); | ||
83 | |||||
84 | 1 | 71.4ms | 1 | 71.4ms | while(<$jhandle>) { # spent 71.4ms making 1 call to Runner::CORE:readline |
85 | 1180507 | 4.69s | 1180507 | 1.06s | if (/^===END MESSAGE DATA===$/) { # spent 1.06s making 1180507 calls to Runner::CORE:match, avg 898ns/call |
86 | 1 | 700ns | $mode = 1; | ||
87 | 1 | 2µs | last; | ||
88 | } | ||||
89 | |||||
90 | 1180506 | 398ms | chomp; | ||
91 | 1180506 | 1.04s | push (@todecode, $_); | ||
92 | 1180506 | 92.3s | 1180506 | 86.4s | if(@todecode > 1000) { #wait for a decent amount of messages, # spent 86.4s making 1180506 calls to Runner::CORE:readline, avg 73µs/call |
93 | |||||
94 | # and then append them to the data already available | ||||
95 | 1179 | 264ms | my $rv = eval(' @{$data->{msg_data}} = (@{$data->{msg_data}} , $json->incr_parse(join " ",@todecode)); '); # spent 4.25s executing statements in 1179 string evals (merged) | ||
96 | 1179 | 1.13ms | if (!defined($rv)) { | ||
97 | warn "/!\\ Error with the json parsing =======================\n"; | ||||
98 | print $@; | ||||
99 | confess; | ||||
100 | } | ||||
101 | |||||
102 | #clean the buffer | ||||
103 | 1179 | 193ms | @todecode = (); #We used the data, reset the array | ||
104 | |||||
105 | # then parse them (which will remove those parsed from $data) | ||||
106 | 1179 | 7.64ms | 1179 | 10.7s | Runner::Stats::computeOnMessages($data, $sinalgo_command); # spent 10.7s making 1179 calls to Runner::Stats::computeOnMessages, avg 9.08ms/call |
107 | } | ||||
108 | } | ||||
109 | |||||
110 | 1 | 1.21ms | 1 | 859µs | @{$data->{msg_data}} = (@{$data->{msg_data}} , $json->incr_parse(join " ",@todecode)); # spent 859µs making 1 call to JSON::XS::incr_parse |
111 | 1 | 36µs | undef @todecode; | ||
112 | 1 | 88µs | 1 | 4.03ms | Runner::Stats::computeOnMessages($data, $sinalgo_command); # spent 4.03ms making 1 call to Runner::Stats::computeOnMessages |
113 | #print "Trigger data :".total_size($data).", data->msgdata :".total_size($data->{msg_data}).", data->dr:".total_size($data->{delivery_rolling})."\n"; | ||||
114 | |||||
115 | } elsif ($mode == 1) { | ||||
116 | 1 | 112ms | 1 | 112ms | my @array = ($_,<$jhandle>); # spent 112ms making 1 call to Runner::CORE:readline |
117 | 1 | 3.95ms | 3 | 3.76ms | my $res = JSON::XS->new->relaxed->decode(join " ",@array); # spent 3.74ms making 1 call to JSON::XS::decode
# spent 16µs making 1 call to JSON::XS::new
# spent 3µs making 1 call to JSON::XS::relaxed |
118 | 1 | 13µs | 1 | 5µs | for (keys %{$res}) { # spent 5µs making 1 call to JSON::XS::DESTROY |
119 | 2 | 14µs | $data->{$_} = $res->{$_}; | ||
120 | } | ||||
121 | |||||
122 | 1 | 100µs | last THIS_SIMULATION; | ||
123 | } else { | ||||
124 | confess("should not happen, strange file format..."); | ||||
125 | } | ||||
126 | } | ||||
127 | |||||
128 | 1 | 119µs | 1 | 97µs | close($jhandle) or confess("Bad filehandle : ".$!); # spent 97µs making 1 call to Runner::CORE:close |
129 | |||||
130 | 1 | 8µs | 1 | 5.64ms | Runner::Stats::computeOnMessages($data, $sinalgo_command); # spent 5.64ms making 1 call to Runner::Stats::computeOnMessages |
131 | |||||
132 | |||||
133 | # Runner::IO::tprint "### All messages parsed, doing global stuff\n"; | ||||
134 | 1 | 10µs | 1 | 7.04ms | Runner::Stats::computeAtTheEnd($data, $sinalgo_command); # spent 7.04ms making 1 call to Runner::Stats::computeAtTheEnd |
135 | |||||
- - | |||||
138 | # Dumping results; | ||||
139 | |||||
140 | 1 | 16µs | 1 | 9µs | if($run_name =~ /^\s*$/) { # spent 9µs making 1 call to Runner::CORE:match |
141 | die("run name empty ?!"); | ||||
142 | } | ||||
143 | |||||
144 | 1 | 6.41ms | 1 | 6.36ms | `rm -rf ../results/$run_name/`; # spent 6.36ms making 1 call to Runner::CORE:backtick |
145 | 1 | 63µs | 1 | 46µs | mkdir("../results/$run_name"); # spent 46µs making 1 call to Runner::CORE:mkdir |
146 | |||||
147 | 1 | 12µs | 1 | 27.6ms | Runner::IO::dump_averages($data,$run_name); # spent 27.6ms making 1 call to Runner::IO::dump_averages |
148 | 1 | 6µs | 1 | 139µs | Runner::IO::dump_globals($data,$run_name); # spent 139µs making 1 call to Runner::IO::dump_globals |
149 | 1 | 4µs | 1 | 1.76ms | Runner::IO::dump_node_data($data,$run_name); # spent 1.76ms making 1 call to Runner::IO::dump_node_data |
150 | |||||
151 | #This would be to dump all the message data, which is huge | ||||
152 | #Runner::IO::dump_raw($data,$run_name); | ||||
153 | |||||
154 | 1 | 4.35ms | undef $data; | ||
155 | |||||
156 | |||||
157 | 1 | 22µs | 1 | 72µs | Runner::IO::tprint "### Done with this simulation, onto the next\n"; # spent 72µs making 1 call to Runner::IO::tprint |
158 | |||||
159 | } #End foreach run of simulation | ||||
160 | |||||
161 | |||||
162 | 1 | 200ns | exit(0); | ||
163 | |||||
# spent 10µs within Internals::SvREADONLY which was called:
# once (10µs+0s) by constant::import at line 136 of constant.pm | |||||
# spent 6.36ms within Runner::CORE:backtick which was called:
# once (6.36ms+0s) by main::RUNTIME at line 144 | |||||
# spent 97µs within Runner::CORE:close which was called:
# once (97µs+0s) by main::RUNTIME at line 128 | |||||
# spent 1.06s within Runner::CORE:match which was called 1180789 times, avg 898ns/call:
# 1180507 times (1.06s+0s) by main::RUNTIME at line 85, avg 898ns/call
# 142 times (510µs+0s) by main::RUNTIME at line 70, avg 4µs/call
# 137 times (149µs+0s) by main::RUNTIME at line 73, avg 1µs/call
# 2 times (3µs+0s) by main::RUNTIME at line 79, avg 2µs/call
# once (9µs+0s) by main::RUNTIME at line 140 | |||||
sub Runner::CORE:mkdir; # opcode | |||||
# spent 87.4s within Runner::CORE:readline which was called 1180650 times, avg 74µs/call:
# 1180506 times (86.4s+0s) by main::RUNTIME at line 92, avg 73µs/call
# 141 times (764ms+0s) by main::RUNTIME at line 69, avg 5.42ms/call
# once (112ms+0s) by main::RUNTIME at line 116
# once (71.4ms+0s) by main::RUNTIME at line 84
# once (12µs+0s) by main::RUNTIME at line 79 | |||||
# spent 18µs within UNIVERSAL::can which was called:
# once (18µs+0s) by attributes::import at line 59 of attributes.pm | |||||
# spent 5µs within mro::method_changed_in which was called:
# once (5µs+0s) by constant::import at line 151 of constant.pm | |||||
# spent 14µs within version::(bool which was called:
# once (14µs+0s) by DynaLoader::BEGIN@22 at line 59 of Config.pm | |||||
# spent 13µs within version::(cmp which was called:
# once (13µs+0s) by DynaLoader::BEGIN@22 at line 62 of Config.pm |