Skip to content

Instantly share code, notes, and snippets.

@Skarsnik
Last active July 29, 2017 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Skarsnik/1c356d1d3b115ce08a4368778b6999b4 to your computer and use it in GitHub Desktop.
Save Skarsnik/1c356d1d3b115ce08a4368778b6999b4 to your computer and use it in GitHub Desktop.
Benchmarking "normal" usage of Perl6.
Gumbo:
The first test is just parsing a sizeable HTML page (saved localy, around 260Kb, 11 000+ html elements) using the Gumbo module.
The Gumbo module use a C library that parse HTML5 quite quickly then create Perl 6 XML object from the C structures.
The *XML* result is the time for Perl 6 to go through the C object and create these XML objects (html parse is done in ~0.04 sec by C)
The *Dummy* result is a the time to goes through the C tree without creating the object.
MiniGumbo:
To try to track down a bit what is very slow in this. I created a smaller version the Gumbo module and the XML module.
The *XML* and *Dummy* and the same thing that for Gumbo.
Result for dummy where multiplied by 10 or 5 to make them closer to the XML result on the SVG graph
The test machine is a vps running debian 7.11
skarsnik@vps300582:~/perl6/benchmark$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 42
model name : Intel Xeon E312xx (Sandy Bridge)
stepping : 1
microcode : 0x1
cpu MHz : 2394.470
cache size : 4096 KB
skarsnik@vps300582:~/perl6/benchmark$ uname -a
Linux vps300582.ovh.net 3.2.0-4-amd64 #1 SMP Debian 3.2.78-1 x86_64 GNU/Linux
MiniGumbo code can be found at http://www.nyo.fr/~skarsnik/tmp/minigumbo/
I made profile for each rakudo (only 2017.07 is wrong)
http://www.nyo.fr/~skarsnik/tmp/gumbo_test_profile/
## Gumbo
("rakudo-2016.01.1" => ${:dummy(0.2932959897), :xml(5.4256497682)},
"rakudo-2016.02" => ${:dummy(0.28999616828), :xml(4.98068756114)},
"rakudo-2016.03" => ${:dummy(0.25536718099), :xml(4.6855993369)},
"rakudo-2016.04" => ${:dummy(0.2589546308), :xml(4.88365493323)},
"rakudo-2016.05" => ${:dummy(0.21124132721), :xml(4.67598129068)},
"rakudo-2016.06" => ${:dummy(0.2024855946), :xml(3.85390188239)},
"rakudo-2016.07.1" => ${:dummy(0.20372138913), :xml(2.7443396464)},
"rakudo-2016.08.1" => ${:dummy(0.2081381201), :xml(2.66515824645)},
"rakudo-2016.09" => ${:dummy(0.20934949138), :xml(2.5724873365)},
"rakudo-2016.10" => ${:dummy(0.32920357851), :xml(2.87534449295)},
"rakudo-2016.11" => ${:dummy(0.32041531332), :xml(2.7915202029)},
"rakudo-2016.12" => ${:dummy(0.32858521324), :xml(1.9209303991)},
"rakudo-2017.01" => ${:dummy(0.29494166508), :xml(1.73853261392)},
"rakudo-2017.02" => ${:dummy(0.28996514255), :xml(1.8001120085)},
"rakudo-2017.03" => ${:dummy(0.30766137639), :xml(1.87796574266)},
"rakudo-2017.04.3" => ${:dummy(0.2975985048), :xml(1.8534360435)},
"rakudo-2017.05" => ${:dummy(0.29487860953), :xml(1.82722038514)},
"rakudo-2017.06" => ${:dummy(0.27619376261), :xml(1.86392477792)},
"rakudo-2017.07" => ${:dummy(0.27576646839), :xml(1.8828622272)})
## Mini Gumbo
("rakudo-2016.01.1" => ${:dummy(0.34334815997), :xml(1.76401997496)},
"rakudo-2016.02" => ${:dummy(0.34316261214), :xml(1.63999218913)},
"rakudo-2016.03" => ${:dummy(0.3054681681), :xml(1.563797504)},
"rakudo-2016.04" => ${:dummy(0.31289188537), :xml(1.61975772933)},
"rakudo-2016.05" => ${:dummy(0.251099813), :xml(1.47670215392)},
"rakudo-2016.06" => ${:dummy(0.23329444053), :xml(1.19284221809)},
"rakudo-2016.07.1" => ${:dummy(0.23008050364), :xml(1.03410680454)},
"rakudo-2016.08.1" => ${:dummy(0.23968625778), :xml(1.05659187848)},
"rakudo-2016.09" => ${:dummy(0.22813648523), :xml(0.98674339355)},
"rakudo-2016.10" => ${:dummy(0.35553774577), :xml(1.22431721976)},
"rakudo-2016.11" => ${:dummy(0.36891173641), :xml(1.2892212456)},
"rakudo-2016.12" => ${:dummy(0.37262180886), :xml(1.3415993328)},
"rakudo-2017.01" => ${:dummy(0.3391793392), :xml(1.22221678)},
"rakudo-2017.02" => ${:dummy(0.3316574133), :xml(1.2617083224)},
"rakudo-2017.03" => ${:dummy(0.34626731862), :xml(1.29301429322)},
"rakudo-2017.04.3" => ${:dummy(0.35871427558), :xml(1.31285384948)},
"rakudo-2017.05" => ${:dummy(0.34172124903), :xml(1.27149396035)},
"rakudo-2017.06" => ${:dummy(0.30962216678), :xml(1.20797171994)},
"rakudo-2017.07" => ${:dummy(0.31063276063), :xml(1.229624305035)})
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
use v6;
my $bench-dir = "/home/skarsnik/perl6/benchmark/";
my $torun = "-I $bench-dir/perl6-gumbo/lib -I $bench-dir/exemel/lib/ -I $bench-dir/minigumbo $bench-dir/benchminigumbo.p6";
my %result;
my $runs = 100;
for "rakudoversion.txt".IO.lines -> $file is copy {
$file = "rakudo-" ~ $file;
say $file;
my $xml = 0;
my $dummy = 0;
for 1..$runs {
my $proc = shell "PERL6_GUMBOLIB=/usr/local/lib/libgumbo.so.1 " ~ $file.IO.path ~ '/install/bin/perl6 ' ~ $torun, :out;
for $proc.out.lines -> $line {
if $line ~~ /^'XML: '(\d+'.'\d+)/ {
$xml += $0;
}
if $line ~~ /^'Dummy: '(\d+'.'\d+)/ {
$dummy += $0;
}
}
}
%result{$file}<xml> = $xml / $runs;
%result{$file}<dummy> = $dummy / $runs;
}
say %result.sort.perl;
use Gumbo::Parser;
my $parser = Gumbo::Parser.new;
my $html = "/home/skarsnik/perl6/benchmark/fimfav.html".IO.slurp;
my $xml = $parser.parse($html);
say "XML objects: " ~ $parser.stats<xml-objects>;
say "Gumbo: " ~ $parser.c-parse-duration;
say "XML: " ~ $parser.xml-creation-duration;
$xml = $parser.parse($html, :dummy);
say "Dummy: " ~ $parser.xml-creation-duration;
skarsnik@vps300582:~/perl6/benchmark$ cat benchminigumbo.p6
use MiniGumbo;
my $html = "/home/skarsnik/perl6/benchmark/fimfav.html".IO.slurp;
parse-html($html);
say "Gumbo: " ~ %minigumbo-stats<c-parse-duration>;
say "XML: " ~ %minigumbo-stats<xml-creation-duration>;
parse-html($html, :dummy);
say "Dummy: " ~ %minigumbo-stats<xml-creation-duration>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment