← 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.pl
StatementsExecuted 4727369 statements in 99.9s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11806505187.4s87.4sRunner::::CORE:readline Runner::CORE:readline (opcode)
1180789511.06s1.06sRunner::::CORE:match Runner::CORE:match (opcode)
11114.6ms33.3msRunner::::BEGIN@12 Runner::BEGIN@12
1117.74ms7.87msRunner::::BEGIN@8 Runner::BEGIN@8
1116.50ms6.63msRunner::::BEGIN@10 Runner::BEGIN@10
1116.36ms6.36msRunner::::CORE:backtick Runner::CORE:backtick (opcode)
1114.21ms18.1msRunner::::BEGIN@11 Runner::BEGIN@11
1113.56ms20.0msRunner::::BEGIN@15 Runner::BEGIN@15
1111.38ms1.50msRunner::::BEGIN@17 Runner::BEGIN@17
1111.02ms1.14msRunner::::BEGIN@9 Runner::BEGIN@9
111859µs1.49msRunner::::BEGIN@14 Runner::BEGIN@14
11197µs97µsRunner::::CORE:close Runner::CORE:close (opcode)
22180µs80µsRunner::::CORE:mkdir Runner::CORE:mkdir (opcode)
11120µs141µsRunner::::BEGIN@13 Runner::BEGIN@13
11118µs18µsUNIVERSAL::::canUNIVERSAL::can (xsub)
11114µs14µsRunner::::BEGIN@16 Runner::BEGIN@16
11114µs14µsversion::::(bool version::(bool (xsub)
11113µs13µsversion::::(cmp version::(cmp (xsub)
11110µs10µsInternals::::SvREADONLYInternals::SvREADONLY (xsub)
1115µs5µsmro::::method_changed_in mro::method_changed_in (xsub)
0000s0smain::::BEGIN main::BEGIN (xsub)
0000s0smain::::RUNTIME main::RUNTIME
Call graph for these subroutines as a Graphviz dot language file.
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
6package Runner;
7
827.37ms27.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
use warnings;
# spent 7.87ms making 1 call to Runner::BEGIN@8 # spent 28µs making 1 call to warnings::import
921.02ms21.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
use strict;
# spent 1.14ms making 1 call to Runner::BEGIN@9 # spent 60µs making 1 call to strict::import
1024.51ms26.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
use Getopt::Std;
# spent 6.63ms making 1 call to Runner::BEGIN@10 # spent 130µs making 1 call to Exporter::import
112972µs218.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
use JSON::XS;
# spent 18.1ms making 1 call to Runner::BEGIN@11 # spent 125µs making 1 call to Exporter::import
1221.11ms233.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
use Data::Dumper;
# spent 33.3ms making 1 call to Runner::BEGIN@12 # spent 122µs making 1 call to Exporter::import
13268µs2261µs
# spent 141µs (20+120) within Runner::BEGIN@13 which was called: # once (20µs+120µs) by main::RUNTIME at line 13
use Carp qw/confess/;
# spent 141µs making 1 call to Runner::BEGIN@13 # spent 120µs making 1 call to Exporter::import
142229µs21.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
use List::Util;
# spent 1.49ms making 1 call to Runner::BEGIN@14 # spent 21µs making 1 call to List::Util::import
152750µs120.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
use Runner::IO;
# spent 20.0ms making 1 call to Runner::BEGIN@15
16275µs114µs
# spent 14µs within Runner::BEGIN@16 which was called: # once (14µs+0s) by main::RUNTIME at line 16
use Runner::Stats;
# spent 14µs making 1 call to Runner::BEGIN@16
1722.49ms11.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
use Runner::Job;
# spent 1.50ms making 1 call to Runner::BEGIN@17
18
19
2014µs$| = 1;
211600ns$Getopt::Std::STANDARD_HELP_VERSION = 1;
22
23# Parse the cmdline arguments
241600nsmy %opts;
2518µs1170µsgetopt('Nnpard',\%opts); #$opts->{a} is the args
# spent 170µs making 1 call to Getopt::Std::getopt
26
2712µsif (!defined($opts{N}) || !defined($opts{n}) || !defined($opts{p})) {
28 Runner::IO::runner_usage();
29 exit(1);
30}
31
32
331400nsmy @destinations;
341700nsif (defined($opts{d})) {
35 @destinations = split(/ /, $opts{d});
36}
37
3811µsmy $tbegin = time;
39120µsmy ($name, $project) = ($opts{n},$opts{p});
40
41
421700nsmy $nbmsg = 100;
4312µsmy $nbruns = defined($opts{r}) ? $opts{r} : 10;
44
4518µs1144µsRunner::IO::rprint "###### Runner launching campaign ".$opts{n}." \n";
# spent 144µs making 1 call to Runner::IO::rprint
4614µs140µsRunner::IO::tprint "### Running Sinalgo... \n";
# spent 40µs making 1 call to Runner::IO::tprint
47
4819µsmy $sinalgo_command = "cd .. && ./sinalgo".
49 " -batch -project ${project} ".$opts{N}." -overwrite ".$opts{a};
50
51#print $sinalgo_command."\n";
52
53147µs135µsmkdir ("../results");
# spent 35µs making 1 call to Runner::CORE:mkdir
54
5518µs153µsRunner::IO::tprint "### Command : $sinalgo_command\n";
# spent 53µs making 1 call to Runner::IO::tprint
56
5717µsfor my $run (0..$nbruns-1) { ###Running simulations... done !
58
59111µs154µ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
6113µs my $run_name = $name."_".$run;
62
6317µs11.46ms my $jhandle = Runner::Job::getJobHandle($sinalgo_command, $run);
# spent 1.46ms making 1 call to Runner::Job::getJobHandle
64
65116µs193µs Runner::IO::tprint "### Un-JSONify the results\n";
# spent 93µs making 1 call to Runner::IO::tprint
6613µs my $data = {};
671900ns my $mode = -1; # -1 for pre-simulation sinalgo crap
68
691765ms141764ms THIS_SIMULATION: while (<$jhandle>) { #Reading from STDIN
# spent 764ms making 141 calls to Runner::CORE:readline, avg 5.42ms/call
70142938µs142510µ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
7213974µs if ($mode == -1) {
73137471µs137149µ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 }
76137105µs next;
77 }
78
79235µs479µ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
80155µs317µ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
8115µs $data->{msg_data} = [];
8212µs my @todecode = ();
83
84171.4ms171.4ms while(<$jhandle>) {
# spent 71.4ms making 1 call to Runner::CORE:readline
8511805074.69s11805071.06s if (/^===END MESSAGE DATA===$/) {
# spent 1.06s making 1180507 calls to Runner::CORE:match, avg 898ns/call
861700ns $mode = 1;
8712µs last;
88 }
89
901180506398ms chomp;
9111805061.04s push (@todecode, $_);
92118050692.3s118050686.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
951179264ms my $rv = eval(' @{$data->{msg_data}} = (@{$data->{msg_data}} , $json->incr_parse(join " ",@todecode)); ');
# spent 4.25s executing statements in 1179 string evals (merged)
9611791.13ms if (!defined($rv)) {
97 warn "/!\\ Error with the json parsing =======================\n";
98 print $@;
99 confess;
100 }
101
102 #clean the buffer
1031179193ms @todecode = (); #We used the data, reset the array
104
105 # then parse them (which will remove those parsed from $data)
10611797.64ms117910.7s Runner::Stats::computeOnMessages($data, $sinalgo_command);
# spent 10.7s making 1179 calls to Runner::Stats::computeOnMessages, avg 9.08ms/call
107 }
108 }
109
11011.21ms1859µs @{$data->{msg_data}} = (@{$data->{msg_data}} , $json->incr_parse(join " ",@todecode));
# spent 859µs making 1 call to JSON::XS::incr_parse
111136µs undef @todecode;
112188µs14.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) {
1161112ms1112ms my @array = ($_,<$jhandle>);
# spent 112ms making 1 call to Runner::CORE:readline
11713.95ms33.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
118113µs15µs for (keys %{$res}) {
# spent 5µs making 1 call to JSON::XS::DESTROY
119214µs $data->{$_} = $res->{$_};
120 }
121
1221100µs last THIS_SIMULATION;
123 } else {
124 confess("should not happen, strange file format...");
125 }
126 }
127
1281119µs197µs close($jhandle) or confess("Bad filehandle : ".$!);
# spent 97µs making 1 call to Runner::CORE:close
129
13018µs15.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";
134110µs17.04ms Runner::Stats::computeAtTheEnd($data, $sinalgo_command);
# spent 7.04ms making 1 call to Runner::Stats::computeAtTheEnd
135
- -
138 # Dumping results;
139
140116µs19µs if($run_name =~ /^\s*$/) {
# spent 9µs making 1 call to Runner::CORE:match
141 die("run name empty ?!");
142 }
143
14416.41ms16.36ms `rm -rf ../results/$run_name/`;
# spent 6.36ms making 1 call to Runner::CORE:backtick
145163µs146µs mkdir("../results/$run_name");
# spent 46µs making 1 call to Runner::CORE:mkdir
146
147112µs127.6ms Runner::IO::dump_averages($data,$run_name);
# spent 27.6ms making 1 call to Runner::IO::dump_averages
14816µs1139µs Runner::IO::dump_globals($data,$run_name);
# spent 139µs making 1 call to Runner::IO::dump_globals
14914µs11.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
15414.35ms undef $data;
155
156
157122µs172µ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
1621200nsexit(0);
163
 
# spent 10µs within Internals::SvREADONLY which was called: # once (10µs+0s) by constant::import at line 136 of constant.pm
sub Internals::SvREADONLY; # xsub
# spent 6.36ms within Runner::CORE:backtick which was called: # once (6.36ms+0s) by main::RUNTIME at line 144
sub Runner::CORE:backtick; # opcode
# spent 97µs within Runner::CORE:close which was called: # once (97µs+0s) by main::RUNTIME at line 128
sub Runner::CORE:close; # opcode
# 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:match; # opcode
# spent 80µs within Runner::CORE:mkdir which was called 2 times, avg 40µs/call: # once (46µs+0s) by main::RUNTIME at line 145 # once (35µs+0s) by main::RUNTIME at line 53
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
sub Runner::CORE:readline; # opcode
# spent 18µs within UNIVERSAL::can which was called: # once (18µs+0s) by attributes::import at line 59 of attributes.pm
sub UNIVERSAL::can; # xsub
# spent 5µs within mro::method_changed_in which was called: # once (5µs+0s) by constant::import at line 151 of constant.pm
sub mro::method_changed_in; # xsub
# spent 14µs within version::(bool which was called: # once (14µs+0s) by DynaLoader::BEGIN@22 at line 59 of Config.pm
sub version::(bool; # xsub
# spent 13µs within version::(cmp which was called: # once (13µs+0s) by DynaLoader::BEGIN@22 at line 62 of Config.pm
sub version::(cmp; # xsub