Skip to content

Instantly share code, notes, and snippets.

@timo
Created November 6, 2015 00:02
Show Gist options
  • Save timo/49dcb80d6ce40e0613f5 to your computer and use it in GitHub Desktop.
Save timo/49dcb80d6ce40e0613f5 to your computer and use it in GitHub Desktop.
use nqp;
my %stats := BagHash.new();
for lines() {
m:s/ 'demand' (object|stable|code) ':' \( (<-[)]>+) \) (<-[ \s ]>+) (\d+) /;
next unless $/;
state $whatname = "";
state $samewhatcount = 0;
my $kind = $0.Str;
my $sourcefile = $1.Str;
my $sc_handle = $2.Str;
my $sc_index = $3.Int;
my $sc := nqp::createsc($sc_handle);
if (!nqp::scgetdesc($sc)) {
nqp::scsetdesc($sc, "no description");
}
my $target_obj;
try {
$target_obj := nqp::scgetobj($sc, $sc_index);
CATCH {
default {
say "$sc_handle $sc_index couldn't be resolved";
next;
}
}
}
my $this_whatname = (try $target_obj.WHAT.^name) // "could_not_WHAT";
if $whatname eq $this_whatname {
$samewhatcount++;
} else {
say $samewhatcount ~ " x " ~ $whatname;
$whatname = $this_whatname;
$samewhatcount = 1;
%stats{$whatname} += $samewhatcount;
}
}
say " =========== ";
say " leaderboard ";
say " =========== ";
my @leaderboard = %stats.pairs.sort(*.value.Int).map({.value.fmt("%5d") ~ " x " ~ .key}).map(*.say)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment