Skip to content

Instantly share code, notes, and snippets.

@Skarsnik
Created December 7, 2016 13:17
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/e2d531f1095e12fb1d8bc0646ad1d89f to your computer and use it in GitHub Desktop.
Save Skarsnik/e2d531f1095e12fb1d8bc0646ad1d89f to your computer and use it in GitHub Desktop.
Here some performance test of rakudo release on 2 tasks.
The machine used is a debian stable 8.6 32bits in a VM. (no activity on the host/guess during tests)
skarsnik@devel:~/perl6$ uname -a
Linux devel 3.16.0-4-586 #1 Debian 3.16.36-1+deb8u2 (2016-10-19) i686 GNU/Linux
CPU info:
model name : Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz
--
First is the averages of 20 runs of GPTrixie (A tool that generate perl6 NC code from C headers) on each rakudo release.
Run done against a sizable header : libxml2 xmltree.h header.
GPTrixie call a tool (gccxml or cast) to generate a XML file containing type information and declaration.
The resulting XML file is 664Kb with around 8000 lines. The xml tree is not very deep (max depth must be 5?)
The XML parsing part is a basic call to the parse method of the XML module.
Then GPTrixie parse the resulting xml tree objects to generate its own objects (The magic part)
The magic part go through the xml tree, create objects from it, then some of them are read again
to complete missing informations (think of indirect types like pointer)
Time are in seconds and are taken from GPTrixie output:
Eg: Times -- gccxml: 0.28513878 sec; xml parsing: 26.1212995 sec; magic: 3.5215726
"/home/skarsnik/perl6/rakudo-2016.01.1" => ${:magic(3.3220340425), :xmlparsing(25.1521265115)}
"/home/skarsnik/perl6/rakudo-2016.02" => ${:magic(3.13382002095), :xmlparsing(25.263927762)}
"/home/skarsnik/perl6/rakudo-2016.03" => ${:magic(2.7715226725), :xmlparsing(25.280505137)}
"/home/skarsnik/perl6/rakudo-2016.04" => ${:magic(2.83587417755), :xmlparsing(26.3773555315)}
"/home/skarsnik/perl6/rakudo-2016.05 => ${:magic(2.76005326805), :xmlparsing(25.92278338)}
"/home/skarsnik/perl6/rakudo-2016.06" => ${:magic(2.3961876175), :xmlparsing(23.5649842515)}
"/home/skarsnik/perl6/rakudo-2016.07.1" => ${:magic(1.4048787065), :xmlparsing(19.9636975675)}
"/home/skarsnik/perl6/rakudo-2016.08.1" => ${:magic(1.348656194), :xmlparsing(20.247530672)}
"/home/skarsnik/perl6/rakudo-2016.09" => ${:magic(1.3234498075), :xmlparsing(19.3735762285)}
"/home/skarsnik/perl6/rakudo-2016.10" => ${:magic(1.3275878365), :xmlparsing(19.4487507143)}
"/home/skarsnik/perl6/rakudo-2016.11" => ${:magic(1.3248281345), :xmlparsing(18.87699474245)}
It's interesting to see a huge drop in the magic part between 06 and 07.1 (almost a second, ~40% speed gain)
and in the end 11 is more than 2 times faster for this part than rakudo 01.
But the XML parsing only get a 28% gain. it's still very slow (gccxml take 0.3 sec to create the file)
I don't have comparaison but the Gumbo C lib (see bellow) take like 4-5 sec to parse huge difficult HTML5 files (over 5M+)
--
Object creation / HTML5 parsing (Gumbo)
Here the averages of 50 runs of parsing a 188k html5 file using the Gumbo binding module.
The Gumbo module run the parse html routine of the C lib, then just copy the C structures to perl6 XML object.
I only tracked the time it take to convert the C object to perl6.
"/home/skarsnik/perl6/rakudo-2016.01.1" => ${:xml(2.3340574504)}
"/home/skarsnik/perl6/rakudo-2016.02" => ${:xml(2.2075987956)}
"/home/skarsnik/perl6/rakudo-2016.03" => ${:xml(2.20145841656)}
"/home/skarsnik/perl6/rakudo-2016.04" => ${:xml(2.2438497276)}
"/home/skarsnik/perl6/rakudo-2016.05" => ${:xml(2.1169642338)}
"/home/skarsnik/perl6/rakudo-2016.06" => ${:xml(1.78696139706)}
"/home/skarsnik/perl6/rakudo-2016.07.1" => ${:xml(1.2638900214)}
"/home/skarsnik/perl6/rakudo-2016.08.1" => ${:xml(1.24521332302)}
"/home/skarsnik/perl6/rakudo-2016.09" => ${:xml(1.2391516516)}
"/home/skarsnik/perl6/rakudo-2016.10" => ${:xml(1.3663820254)}
"/home/skarsnik/perl6/rakudo-2016.11" => ${:xml(1.3677555656)})
It's interesting that the first big gap happened between 05 and 06 and not 06 and 07 like for GPTrixie.
We gain a 1 second over rakudo 01.1.
It's still very slow considering gumbo take between 0.02 and 0.03 second to do the full parsing and C structures creation.
use v6;
my $torun = "-I /home/skarsnik/perl6/gptrixie/lib -I /home/skarsnik/perl6/exemel/lib/ /home/skarsnik/perl6/gptrixie/bin/gptrixie /usr/include/libxml2/libxml/tree.h -I /usr/include/libxml2/";
my %result;
for dir("/home/skarsnik/perl6") -> $file {
if $file ~~ /rakudo/ and $file.IO ~~ :d {
say $file;
my $xmlparsing = 0;
my $magic = 0;
for 1..20 {
my $proc = shell $file.IO.path ~ '/install/bin/perl6 ' ~ $torun, :err;
for $proc.err.lines -> $line {
if $line ~~ /^Times/ {
#Times -- gccxml: 0.28513878 sec; xml parsing: 26.1212995 sec; magic: 3.5215726
$line ~~ /'xml parsing: '(\d+'.'\d+)' sec; magic: '(\d+'.'\d+)/;
$xmlparsing += $0;
$magic += $1;
}
}
}
%result{$file}<xmlparsing> = $xmlparsing / 20;
%result{$file}<magic> = $magic / 20;
say %result{$file}.perl;
}
}
say %result.perl;
use v6;
my $torun = "-I /home/skarsnik/perl6/perl6-gumbo/lib -I /home/skarsnik/perl6/exemel/lib/ /home/skarsnik/perl6/testgumbo.p6";
my %result;
for dir("/home/skarsnik/perl6") -> $file {
if $file ~~ /rakudo/ and $file.IO ~~ :d {
say $file;
my $xml = 0;
for 1..50 {
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;
}
}
}
%result{$file}<xml> = $xml / 50;
}
}
say %result.sort.perl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment