Last active
July 29, 2017 12:40
-
-
Save Skarsnik/1c356d1d3b115ce08a4368778b6999b4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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)}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<svg xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="800" height="550"><g transform="translate(128,430)"><line x1="16.842105" y1="-354.77272791091" x2="50.526316" y2="-298.16266533082" style="stroke:green; stroke-width: 1.5" /> | |
<line x1="50.526316" y1="-298.16266533082" x2="84.210526" y2="-263.38508815637" style="stroke:green; stroke-width: 1.5" /> | |
<line x1="84.210526" y1="-263.38508815637" x2="117.894737" y2="-288.92704100772" style="stroke:green; stroke-width: 1.5" /> | |
<line x1="117.894737" y1="-288.92704100772" x2="151.578947" y2="-223.63211517964" style="stroke:green; stroke-width: 1.5" /> | |
<line x1="151.578947" y1="-223.63211517964" x2="185.263158" y2="-94.06978667574" style="stroke:green; stroke-width: 1.5" /> | |
<line x1="185.263158" y1="-94.06978667574" x2="218.947368" y2="-21.61810470297" style="stroke:green; stroke-width: 1.5" /> | |
<line x1="218.947368" y1="-21.61810470297" x2="252.631579" y2="-31.88097793209" style="stroke:green; stroke-width: 1.5" /> | |
<line x1="252.631579" y1="-31.88097793209" x2="286.315789" y2="0" style="stroke:green; stroke-width: 1.5" /> | |
<line x1="286.315789" y1="0" x2="320" y2="-108.43593698894" style="stroke:green; stroke-width: 1.5" /> | |
<line x1="320" y1="-108.43593698894" x2="353.684211" y2="-138.06011305493" style="stroke:green; stroke-width: 1.5" /> | |
<line x1="353.684211" y1="-138.06011305493" x2="387.368421" y2="-161.96706885822" style="stroke:green; stroke-width: 1.5" /> | |
<line x1="387.368421" y1="-161.96706885822" x2="421.052632" y2="-107.47723224820" style="stroke:green; stroke-width: 1.5" /> | |
<line x1="421.052632" y1="-107.47723224820" x2="454.736842" y2="-125.50237614388" style="stroke:green; stroke-width: 1.5" /> | |
<line x1="454.736842" y1="-125.50237614388" x2="488.421053" y2="-139.79137562404" style="stroke:green; stroke-width: 1.5" /> | |
<line x1="488.421053" y1="-139.79137562404" x2="522.105263" y2="-148.84675393241" style="stroke:green; stroke-width: 1.5" /> | |
<line x1="522.105263" y1="-148.84675393241" x2="555.789474" y2="-129.96883963049" style="stroke:green; stroke-width: 1.5" /> | |
<line x1="555.789474" y1="-129.96883963049" x2="589.473684" y2="-100.97535256005" style="stroke:green; stroke-width: 1.5" /> | |
<line x1="589.473684" y1="-100.97535256005" x2="623.157895" y2="-110.85825250095" style="stroke:green; stroke-width: 1.5" /> | |
<line x1="16.842105" y1="-333.19307103160" x2="50.526316" y2="-332.76962260036" style="stroke:red; stroke-width: 1.5" /> | |
<line x1="50.526316" y1="-332.76962260036" x2="84.210526" y2="-246.74515551236" style="stroke:red; stroke-width: 1.5" /> | |
<line x1="84.210526" y1="-246.74515551236" x2="117.894737" y2="-263.68720992457" style="stroke:red; stroke-width: 1.5" /> | |
<line x1="117.894737" y1="-263.68720992457" x2="151.578947" y2="-122.66828177028" style="stroke:red; stroke-width: 1.5" /> | |
<line x1="151.578947" y1="-122.66828177028" x2="185.263158" y2="-82.03370770919" style="stroke:red; stroke-width: 1.5" /> | |
<line x1="185.263158" y1="-82.03370770919" x2="218.947368" y2="-74.69901382371" style="stroke:red; stroke-width: 1.5" /> | |
<line x1="218.947368" y1="-74.69901382371" x2="252.631579" y2="-96.62080898257" style="stroke:red; stroke-width: 1.5" /> | |
<line x1="252.631579" y1="-96.62080898257" x2="286.315789" y2="-70.26246748410" style="stroke:red; stroke-width: 1.5" /> | |
<line x1="286.315789" y1="-70.26246748410" x2="320" y2="-361.01156389373" style="stroke:red; stroke-width: 1.5" /> | |
<line x1="320" y1="-361.01156389373" x2="353.684211" y2="-391.53304914033" style="stroke:red; stroke-width: 1.5" /> | |
<line x1="353.684211" y1="-391.53304914033" x2="387.368421" y2="-400" style="stroke:red; stroke-width: 1.5" /> | |
<line x1="387.368421" y1="-400" x2="421.052632" y2="-323.67918657839" style="stroke:red; stroke-width: 1.5" /> | |
<line x1="421.052632" y1="-323.67918657839" x2="454.736842" y2="-306.51300510251" style="stroke:red; stroke-width: 1.5" /> | |
<line x1="454.736842" y1="-306.51300510251" x2="488.421053" y2="-339.85503604016" style="stroke:red; stroke-width: 1.5" /> | |
<line x1="488.421053" y1="-339.85503604016" x2="522.105263" y2="-368.26088912066" style="stroke:red; stroke-width: 1.5" /> | |
<line x1="522.105263" y1="-368.26088912066" x2="555.789474" y2="-329.48021227542" style="stroke:red; stroke-width: 1.5" /> | |
<line x1="555.789474" y1="-329.48021227542" x2="589.473684" y2="-256.22521369685" style="stroke:red; stroke-width: 1.5" /> | |
<line x1="589.473684" y1="-256.22521369685" x2="623.157895" y2="-258.53154290803" style="stroke:red; stroke-width: 1.5" /> | |
<text transform="rotate(-90)" y="17.010526" x="-7.5" font-size="12" dominant-baseline="middle" text-anchor="end">rakudo-2016.01.1</text> | |
<text transform="rotate(-90)" y="50.694737" x="-7.5" font-size="12" dominant-baseline="middle" text-anchor="end">rakudo-2016.02</text> | |
<text transform="rotate(-90)" y="84.378947" x="-7.5" font-size="12" dominant-baseline="middle" text-anchor="end">rakudo-2016.03</text> | |
<text transform="rotate(-90)" y="118.063158" x="-7.5" font-size="12" dominant-baseline="middle" text-anchor="end">rakudo-2016.04</text> | |
<text transform="rotate(-90)" y="151.747368" x="-7.5" font-size="12" dominant-baseline="middle" text-anchor="end">rakudo-2016.05</text> | |
<text transform="rotate(-90)" y="185.431579" x="-7.5" font-size="12" dominant-baseline="middle" text-anchor="end">rakudo-2016.06</text> | |
<text transform="rotate(-90)" y="219.115789" x="-7.5" font-size="12" dominant-baseline="middle" text-anchor="end">rakudo-2016.07.1</text> | |
<text transform="rotate(-90)" y="252.8" x="-7.5" font-size="12" dominant-baseline="middle" text-anchor="end">rakudo-2016.08.1</text> | |
<text transform="rotate(-90)" y="286.484211" x="-7.5" font-size="12" dominant-baseline="middle" text-anchor="end">rakudo-2016.09</text> | |
<text transform="rotate(-90)" y="320.168421" x="-7.5" font-size="12" dominant-baseline="middle" text-anchor="end">rakudo-2016.10</text> | |
<text transform="rotate(-90)" y="353.852632" x="-7.5" font-size="12" dominant-baseline="middle" text-anchor="end">rakudo-2016.11</text> | |
<text transform="rotate(-90)" y="387.536842" x="-7.5" font-size="12" dominant-baseline="middle" text-anchor="end">rakudo-2016.12</text> | |
<text transform="rotate(-90)" y="421.221053" x="-7.5" font-size="12" dominant-baseline="middle" text-anchor="end">rakudo-2017.01</text> | |
<text transform="rotate(-90)" y="454.905263" x="-7.5" font-size="12" dominant-baseline="middle" text-anchor="end">rakudo-2017.02</text> | |
<text transform="rotate(-90)" y="488.589474" x="-7.5" font-size="12" dominant-baseline="middle" text-anchor="end">rakudo-2017.03</text> | |
<text transform="rotate(-90)" y="522.273684" x="-7.5" font-size="12" dominant-baseline="middle" text-anchor="end">rakudo-2017.04.3</text> | |
<text transform="rotate(-90)" y="555.957895" x="-7.5" font-size="12" dominant-baseline="middle" text-anchor="end">rakudo-2017.05</text> | |
<text transform="rotate(-90)" y="589.642105" x="-7.5" font-size="12" dominant-baseline="middle" text-anchor="end">rakudo-2017.06</text> | |
<text transform="rotate(-90)" y="623.326316" x="-7.5" font-size="12" dominant-baseline="middle" text-anchor="end">rakudo-2017.07</text> | |
<line x1="-3.75" x2="3.75" y1="16.77080498012" y2="16.77080498012" style="stroke:black; stroke-width: 1" /> | |
<text x="-11.25" y="16.77080498012" font-size="12" text-anchor="end" dominant-baseline="middle">0.95</text> | |
<line x1="-3.75" x2="3.75" y1="-6.05071932642" y2="-6.05071932642" style="stroke:black; stroke-width: 1" /> | |
<text x="-11.25" y="-6.05071932642" font-size="12" text-anchor="end" dominant-baseline="middle">1</text> | |
<line x1="-3.75" x2="3.75" y1="-28.87224363295" y2="-28.87224363295" style="stroke:black; stroke-width: 1" /> | |
<text x="-11.25" y="-28.87224363295" font-size="12" text-anchor="end" dominant-baseline="middle">1.05</text> | |
<line x1="-3.75" x2="3.75" y1="-51.69376793948" y2="-51.69376793948" style="stroke:black; stroke-width: 1" /> | |
<text x="-11.25" y="-51.69376793948" font-size="12" text-anchor="end" dominant-baseline="middle">1.1</text> | |
<line x1="-3.75" x2="3.75" y1="-74.51529224601" y2="-74.51529224601" style="stroke:black; stroke-width: 1" /> | |
<text x="-11.25" y="-74.51529224601" font-size="12" text-anchor="end" dominant-baseline="middle">1.15</text> | |
<line x1="-3.75" x2="3.75" y1="-97.33681655254" y2="-97.33681655254" style="stroke:black; stroke-width: 1" /> | |
<text x="-11.25" y="-97.33681655254" font-size="12" text-anchor="end" dominant-baseline="middle">1.2</text> | |
<line x1="-3.75" x2="3.75" y1="-120.15834085907" y2="-120.15834085907" style="stroke:black; stroke-width: 1" /> | |
<text x="-11.25" y="-120.15834085907" font-size="12" text-anchor="end" dominant-baseline="middle">1.25</text> | |
<line x1="-3.75" x2="3.75" y1="-142.97986516560" y2="-142.97986516560" style="stroke:black; stroke-width: 1" /> | |
<text x="-11.25" y="-142.97986516560" font-size="12" text-anchor="end" dominant-baseline="middle">1.3</text> | |
<line x1="-3.75" x2="3.75" y1="-165.80138947213" y2="-165.80138947213" style="stroke:black; stroke-width: 1" /> | |
<text x="-11.25" y="-165.80138947213" font-size="12" text-anchor="end" dominant-baseline="middle">1.35</text> | |
<line x1="-3.75" x2="3.75" y1="-188.62291377866" y2="-188.62291377866" style="stroke:black; stroke-width: 1" /> | |
<text x="-11.25" y="-188.62291377866" font-size="12" text-anchor="end" dominant-baseline="middle">1.4</text> | |
<line x1="-3.75" x2="3.75" y1="-211.44443808519" y2="-211.44443808519" style="stroke:black; stroke-width: 1" /> | |
<text x="-11.25" y="-211.44443808519" font-size="12" text-anchor="end" dominant-baseline="middle">1.45</text> | |
<line x1="-3.75" x2="3.75" y1="-234.26596239173" y2="-234.26596239173" style="stroke:black; stroke-width: 1" /> | |
<text x="-11.25" y="-234.26596239173" font-size="12" text-anchor="end" dominant-baseline="middle">1.5</text> | |
<line x1="-3.75" x2="3.75" y1="-257.08748669826" y2="-257.08748669826" style="stroke:black; stroke-width: 1" /> | |
<text x="-11.25" y="-257.08748669826" font-size="12" text-anchor="end" dominant-baseline="middle">1.55</text> | |
<line x1="-3.75" x2="3.75" y1="-279.90901100479" y2="-279.90901100479" style="stroke:black; stroke-width: 1" /> | |
<text x="-11.25" y="-279.90901100479" font-size="12" text-anchor="end" dominant-baseline="middle">1.6</text> | |
<line x1="-3.75" x2="3.75" y1="-302.73053531132" y2="-302.73053531132" style="stroke:black; stroke-width: 1" /> | |
<text x="-11.25" y="-302.73053531132" font-size="12" text-anchor="end" dominant-baseline="middle">1.65</text> | |
<line x1="-3.75" x2="3.75" y1="-325.55205961785" y2="-325.55205961785" style="stroke:black; stroke-width: 1" /> | |
<text x="-11.25" y="-325.55205961785" font-size="12" text-anchor="end" dominant-baseline="middle">1.7</text> | |
<line x1="-3.75" x2="3.75" y1="-348.37358392438" y2="-348.37358392438" style="stroke:black; stroke-width: 1" /> | |
<text x="-11.25" y="-348.37358392438" font-size="12" text-anchor="end" dominant-baseline="middle">1.75</text> | |
<line x1="-3.75" x2="3.75" y1="-371.19510823091" y2="-371.19510823091" style="stroke:black; stroke-width: 1" /> | |
<text x="-11.25" y="-371.19510823091" font-size="12" text-anchor="end" dominant-baseline="middle">1.8</text> | |
<line x1="-3.75" x2="3.75" y1="-394.01663253744" y2="-394.01663253744" style="stroke:black; stroke-width: 1" /> | |
<text x="-11.25" y="-394.01663253744" font-size="12" text-anchor="end" dominant-baseline="middle">1.85</text> | |
<line x1="0" y1="0" x2="640" y2="0" style="stroke:black; stroke-width: 2" /> | |
<line x1="0" y1="0" x2="0" y2="-400" style="stroke:black; stroke-width: 2" /> | |
<text x="400" y="-415" text-anchor="middle">resultminigumbo.txt</text></g> | |
<g transform="translate(365.6,501.4)"><rect x="0" y="0" height="43.6" width="68.8" style="stroke: black; strok-width: 0.5; fill: none" /> | |
<rect x="10" y="5" height="12" width="12" style="stroke: black; stroke-width: 0.2; fill: green;" /> | |
<text x="24" y="11" dominant-baseline="central">xml</text><rect x="10" y="21.8" height="12" width="12" style="stroke: black; stroke-width: 0.2; fill: red;" /> | |
<text x="24" y="27.8" dominant-baseline="central">dummy</text></g> | |
</svg> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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