Skip to content

Commit

Permalink
[tools] pprof2cg.pl: Fourth tuning: reorder if ladder by pass frequency
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.parrot.org/parrot/trunk@42180 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
japhb committed Oct 31, 2009
1 parent 38f2702 commit ba4eccf
Showing 1 changed file with 33 additions and 36 deletions.
69 changes: 33 additions & 36 deletions tools/dev/pprof2cg.pl
Expand Up @@ -156,23 +156,31 @@ sub main {
=cut

sub process_line {

my $line = shift;
my $stats = shift;
my $ctx_stack = shift;
my ($line, $stats, $ctx_stack) = @_;

for ($line) {
if (/^#/) {
#comments are always ignored
}
elsif (/^VERSION:(\d+)$/) {
my $version = $1;
if ($version != 1) {
die "profile was generated by an incompatible version of the profiling runcore.";
if (/^OP:(.*)$/) {
# Decode string in the format C<{x{key1:value1}x}{x{key2:value2}x}>
my %op_hash = $1 =~ /{x{([^:]+):(.*?)}x}/g
or die "invalidly formed line '$line'";

my $cur_ctx = $ctx_stack->[0]
or die "input file did not specify an initial context";

if (exists $cur_ctx->{line} && $op_hash{line} == $cur_ctx->{line}) {
$cur_ctx->{op_num}++;
}
}
elsif (/^CLI:(.*)$/) {
$stats->{'global_stats'}{'cli'} = $1;
else {
$cur_ctx->{op_num} = 0;
}

$cur_ctx->{line} = $op_hash{line};
my $extra = { op_name => $op_hash{op} };
my $time = $op_hash{time};

$stats->{global_stats}{total_time} += $time;
store_stats ($stats, $cur_ctx, $time, $extra);
store_stats_stack($stats, $ctx_stack, $time);
}
#context switch
elsif (/^CS:(.*)$/) {
Expand Down Expand Up @@ -214,32 +222,21 @@ sub process_line {
}
#print Dumper($ctx_stack);
}
elsif (/^VERSION:(\d+)$/) {
my $version = $1;
if ($version != 1) {
die "profile was generated by an incompatible version of the profiling runcore.";
}
}
elsif (/^CLI:(.*)$/) {
$stats->{'global_stats'}{'cli'} = $1;
}
elsif (/^END_OF_RUNLOOP$/) {
#end of loop
@$ctx_stack = ();
}
elsif (/^OP:(.*)$/) {
# Decode string in the format C<{x{key1:value1}x}{x{key2:value2}x}>
my %op_hash = $1 =~ /{x{([^:]+):(.*?)}x}/g
or die "invalidly formed line '$line'";

my $cur_ctx = $ctx_stack->[0]
or die "input file did not specify an initial context";

if (exists $cur_ctx->{line} && $op_hash{line} == $cur_ctx->{line}) {
$cur_ctx->{op_num}++;
}
else {
$cur_ctx->{op_num} = 0;
}

$cur_ctx->{line} = $op_hash{line};
my $extra = { op_name => $op_hash{op} };
my $time = $op_hash{time};

$stats->{global_stats}{total_time} += $time;
store_stats ($stats, $cur_ctx, $time, $extra);
store_stats_stack($stats, $ctx_stack, $time);
elsif (/^#/) {
#comments are always ignored
}
else {
die "Unrecognized line format: '$line'";
Expand Down

0 comments on commit ba4eccf

Please sign in to comment.