Skip to content

Instantly share code, notes, and snippets.

@colomon
Created March 3, 2011 15:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save colomon/852937 to your computer and use it in GitHub Desktop.
use v6;
use SVG;
use SVG::Plot;
my %benchmarks;
for lines() -> $line {
my ($rakudo, $benchmark, $time) = $line.split(/\s* "," \s*/);
%benchmarks{$benchmark} //= Hash.new;
%benchmarks{$benchmark}.push($rakudo => $time);
}
# for %benchmarks.keys -> $benchmark {
# my %results = %benchmarks{$benchmark};
# say "\n$benchmark:";
# for %results.keys -> $rakudo {
# say " $rakudo { %results{$rakudo} }";
# }
# }
for %benchmarks.keys -> $benchmark {
my %results = %benchmarks{$benchmark};
my @data = %results.pairs.sort(*.key).grep(*.key ne "latest-rakudo");
@data.push("latest-rakudo" => %results{"latest-rakudo"});
# say :@data.perl;
my $svg = SVG::Plot.new(
:width(800),
:height(550),
:plot-height(400),
:fill-width(1.01), # work a round a common SVG rendering bug
:values(@data>>.values),
:labels(@data>>.keys),
:max-x-labels(20),
:colors<lawngreen red blue yellow lightgrey>,
).plot(:lines);
say SVG.serialize($svg);
}
# vim: ft=perl6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment