├── .gitignore ├── Makefile ├── README.md ├── calc-PRD.pl ├── calc-Pegex.pl ├── calc-RG.pl ├── calc-Rakudo.p6 ├── calc.fan ├── gen-rand-expr.pl └── result ├── ingy-6c31e18-5.20.0 └── ingy-8637d9e-5.20.0 /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.swp 3 | *.swo 4 | *.bak 5 | pl-expr.txt 6 | expr.txt 7 | go 8 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PERL5 ?= $(shell which perl) 2 | PERL6 ?= $(shell which perl6) 3 | datafile := expr.txt 4 | time := $(shell which time) 5 | 6 | # 5k.txt (in seconds): 7 | # 2.462 (PRD) vs 1.662 (RG) (perl 5.16.3) 8 | # 2.457 (PRD) vs 1.739 (RG) (perl 5.18.4) 9 | # 1.436 (PRD) vs 1.556 (RG) (perl 5.20.2) 10 | # 1.755 2.629 2.472 11 | 12 | bench: $(datafile) info pegex prd perl6 fanlang 13 | 14 | .PHONY: info 15 | info: 16 | -@uname -a 17 | -@sysctl -n machdep.cpu.brand_string || \ 18 | grep 'model name' /proc/cpuinfo|head -n1|sed 's/model name\s*: //' 19 | @echo 20 | ls -lh $(datafile) 21 | @echo 22 | 23 | @echo === Perl `$(PERL5) -e 'print $$^V'` eval 24 | sed 's/\^/**/g' $(datafile) > pl-$(datafile) 25 | $(time) $(PERL5) -e 'my $$a = do { local $$/; <> }; eval "print q{Result: }, $$a, qq{\n}"; die $$@ if $$@' < pl-$(datafile) 26 | @echo 27 | 28 | .PHONY: pegex 29 | pegex: 30 | @echo === Perl 5 Pegex `$(PERL5) -MPegex -e 'print $$Pegex::VERSION'` 31 | @#export PERL_PEGEX_DEBUG=1 32 | $(time) $(PERL5) calc-Pegex.pl < $(datafile) 33 | @echo 34 | 35 | .PHONY: prd 36 | prd: 37 | @echo === Perl 5 Parse::RecDescent `$(PERL5) -MParse::RecDescent -e 'print $$Parse::RecDescent::VERSION'` 38 | $(time) $(PERL5) calc-PRD.pl < $(datafile) 39 | @echo 40 | 41 | .PHONY: re-gr 42 | re-gr: 43 | @echo === Perl 5 Regexp::Grammars `$(PERL5) -MRegexp::Grammars -e 'print $$Regexp::Grammars::VERSION'` 44 | $(time) $(PERL5) calc-RG.pl < $(datafile) 45 | @echo 46 | 47 | .PHONY: perl6 48 | perl6: 49 | @echo === Perl 6 Rakudo `$(PERL6) --version|sed 's/This is perl6 version //'` 50 | $(time) $(PERL6) --optimize=3 calc-Rakudo.p6 < $(datafile) 51 | @echo 52 | 53 | .PHONY: fanlang 54 | fanlang: 55 | @echo === fanlang 56 | FANLANG_TIMING=0 FANLANG_DEBUG=0 fan -c --no-runtime-check calc.fan 57 | FANLANG_TIMING=0 FANLANG_DEBUG=0 $(time) resty -e 'require "resty.core" require "jit.opt".start("loopunroll=25", "minstitch=5", "maxtrace=1000", "maxmcode=1000000") -- require "jit.v".on("/dev/stderr")' calc.lua $(datafile) 58 | @echo 59 | 60 | .PHONY: fanlang2 61 | fanlang2: 62 | @echo === fanlang2 63 | FANLANG_TIMING=0 FANLANG_DEBUG=0 fan --no-runtime-check -c calc.fan 64 | FANLANG_TIMING=0 FANLANG_DEBUG=0 LD_LIBRARY_PATH=/opt/luajit21/lib $(time) resty --nginx ../lua-nginx-module/work/nginx/sbin/nginx \ 65 | -I /usr/local/openresty/lualib -e 'require "resty.core" -- require "jit.opt".start("loopunroll=25", "minstitch=5") -- require "jit.v".on("/dev/stderr")' calc.lua $(datafile) 66 | @echo 67 | 68 | $(datafile): gen-rand-expr.pl Makefile 69 | $(PERL5) gen-rand-expr.pl 50000 > $@ 70 | 71 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Name 2 | ==== 3 | 4 | perl-parsing-library-benchmark - Benchmark programs for Perl's parsing libraries 5 | 6 | Table of Contents 7 | ================= 8 | 9 | * [Name](#name) 10 | * [Description](#description) 11 | * [Typical benchmark results](#typical-benchmark-results) 12 | * [15-inch Retina Macbook Pro (mid-2015)](#15-inch-retina-macbook-pro-mid-2015) 13 | * [Author](#author) 14 | * [Copyright and License](#copyright-and-license) 15 | 16 | Description 17 | =========== 18 | 19 | This repos holds a bunch of simple infix arithmetic expression calculators implemented with various different Perl 5 and 20 | Perl 6 parsing libraris and/or builtins: 21 | 22 | * Perl 5 [Pegex](https://metacpan.org/release/Pegex) 23 | * Perl 5 [Regexp::Grammars](https://metacpan.org/release/Parse-RecDescent) 24 | * Perl 5 [Parse::RecDescent](https://metacpan.org/release/Regexp-Grammars) 25 | * Perl 6 [Rakudo](http://rakudo.org/) 26 | * Fanlang (OpenResty Inc.'s Perl 6 dialect targeting OpenResty/LuaJIT). 27 | 28 | Right now only top-down parsers are considered. 29 | 30 | To run the benchmark on your box, just type the `make` command. 31 | 32 | If you want to use a particular perl or perl6 executable, then just make it visible in your `PATH` environment. 33 | 34 | Typical benchmark results 35 | ========================= 36 | 37 | 15-inch Retina Macbook Pro (mid-2015) 38 | ------------------------------------- 39 | 40 | ```console 41 | $ make 42 | Linux fedora64 4.8.13-100.fc23.x86_64 #1 SMP Fri Dec 9 14:51:40 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux 43 | sysctl: cannot stat /proc/sys/machdep/cpu/brand_string: No such file or directory 44 | Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz 45 | 46 | ls -lh expr.txt 47 | -rw-r--r--. 1 agentzh agentzh 556K Feb 1 14:03 expr.txt 48 | 49 | === Perl v5.24.0 eval 50 | sed 's/\^/**/g' expr.txt > pl-expr.txt 51 | /bin/time /opt/perl524/bin/perl -e 'my $a = do { local $/; <> }; eval "print q{Result: }, $a, qq{\n}"; die $@ if $@' < pl-expr.txt 52 | Result: 3.13111475318607e+32 53 | 0.02user 0.00system 0:00.03elapsed 93%CPU (0avgtext+0avgdata 6388maxresident)k 54 | 0inputs+0outputs (0major+829minor)pagefaults 0swaps 55 | 56 | === Perl 5 Pegex 0.63 57 | /bin/time /opt/perl524/bin/perl calc-Pegex.pl < expr.txt 58 | Elapsed: 2.567 sec. 59 | Result: 3.13111475318607e+32 60 | 2.56user 0.01system 0:02.58elapsed 99%CPU (0avgtext+0avgdata 26776maxresident)k 61 | 0inputs+0outputs (0major+5866minor)pagefaults 0swaps 62 | 63 | === Perl 5 Parse::RecDescent 1.967013 64 | /bin/time /opt/perl524/bin/perl calc-PRD.pl < expr.txt 65 | Elapsed: 44.918 sec. 66 | Result: 3.13111475318607e+32 67 | 42.71user 1.99system 0:44.95elapsed 99%CPU (0avgtext+0avgdata 22644maxresident)k 68 | 0inputs+0outputs (0major+1799106minor)pagefaults 0swaps 69 | 70 | === Perl 6 Rakudo This is Rakudo version 2017.01-94-g4e7ab2047 built on MoarVM version 2017.01 implementing Perl 6.c. 71 | /bin/time /home/agentzh/git/rakudo/install/bin/perl6 --optimize=3 calc-Rakudo.p6 < expr.txt 72 | Elapsed: 20.614 sec. 73 | Result: 3.13111475318607e+32 74 | 20.63user 0.18system 0:20.91elapsed 99%CPU (0avgtext+0avgdata 364936maxresident)k 75 | 0inputs+0outputs (0major+87559minor)pagefaults 0swaps 76 | 77 | === fanlang 78 | FANLANG_TIMING=0 FANLANG_DEBUG=0 ../fanlang/bin/fanlang calc.fan 79 | FANLANG_TIMING=0 FANLANG_DEBUG=0 /bin/time resty -e 'require "resty.core" require "jit.opt".start("loopunroll=25", "minstitch=5") -- require "jit.v".on("/dev/stderr")' calc.lua < expr.txt 80 | Elapsed: 0.131 sec 81 | Result: 3.1311147531861e+32 82 | 0.14user 0.01system 0:00.17elapsed 93%CPU (0avgtext+0avgdata 12496maxresident)k 83 | 0inputs+0outputs (0major+4057minor)pagefaults 0swaps 84 | ``` 85 | 86 | It is worth noting that the `Regexp::Grammar` version is just too slow and uses 87 | too much memory to be included in the default benchmark Makefile target. 88 | You can manually run its test like below: 89 | 90 | ```bash 91 | make re-gr 92 | ``` 93 | 94 | [Back to TOC](#table-of-contents) 95 | 96 | Author 97 | ====== 98 | 99 | Yichun Zhang (agentzh) 100 | 101 | [Back to TOC](#table-of-contents) 102 | 103 | Copyright and License 104 | ===================== 105 | 106 | This module is licensed under the BSD license. 107 | 108 | Copyright (C) 2015-2016, by Yichun "agentzh" Zhang (章亦春) , OpenResty Inc. 109 | 110 | All rights reserved. 111 | 112 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 113 | 114 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 115 | 116 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 117 | 118 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 119 | 120 | [Back to TOC](#table-of-contents) 121 | 122 | -------------------------------------------------------------------------------- /calc-PRD.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use v5.10.1; 4 | use strict; 5 | use warnings; 6 | 7 | use Time::HiRes qw( time ); 8 | use List::Util (); 9 | use Parse::RecDescent; 10 | 11 | my $grammar = <<'_EOC_'; 12 | expr: 13 | { 14 | my $list = $item[1]; 15 | my $res = shift @$list; 16 | while (@$list) { 17 | my $op = shift @$list; 18 | my $term = shift @$list; 19 | if ($op eq '+') { 20 | $res += $term; 21 | } else { 22 | $res -= $term; 23 | } 24 | } 25 | $return = $res; 26 | } 27 | 28 | add_op: /[+-]/ 29 | 30 | term: 31 | { 32 | my $list = $item[1]; 33 | my $res = shift @$list; 34 | while (@$list) { 35 | my $op = shift @$list; 36 | my $atom = shift @$list; 37 | if ($op eq '*') { 38 | $res *= $atom; 39 | } else { 40 | $res /= $atom; 41 | } 42 | } 43 | $return = $res; 44 | } 45 | 46 | mul_op: /[*\/]/ 47 | 48 | factor: 49 | { 50 | $return = List::Util::reduce { $b ** $a } reverse @{ $item[1] } 51 | } 52 | 53 | atom: number 54 | | '(' expr ')' { $return = $item{expr}; } 55 | | 56 | 57 | number: /[-+]?\d+(?:\.\d+)?/ 58 | _EOC_ 59 | 60 | #$::RD_HINT = 1; 61 | 62 | my $parser = Parse::RecDescent->new($grammar) or die "failed to instantiate PRD_Calc!\n"; 63 | 64 | my $input = @ARGV ? shift : do { local $/; <> }; 65 | 66 | my $begin = time; 67 | my $res = $parser->expr($input); 68 | my $elapsed = time - $begin; 69 | 70 | printf "Elapsed: %.03f sec.\n", $elapsed; 71 | 72 | if ($res) { 73 | say "Result: $res"; 74 | 75 | } else { 76 | die "Failed to parse text."; 77 | } 78 | -------------------------------------------------------------------------------- /calc-Pegex.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use v5.10.1; 4 | use strict; 5 | use warnings; 6 | 7 | use Time::HiRes qw( time ); 8 | use Pegex qw( pegex ); 9 | 10 | my $grammar = <<_EOC_; 11 | expr: term+ % add-op 12 | 13 | add-op: / ( [+-] ) / 14 | term: factor+ % mul-op 15 | 16 | mul-op: / ( ['*/'] ) / 17 | factor: atom+ % '^' 18 | 19 | atom: number 20 | | /- '(' / expr / ')' -/ 21 | 22 | number: /- ( '-'? DIGIT+ (: '.' DIGIT+ )? ) -/ 23 | _EOC_ 24 | 25 | # use XXX; XXX pegex($grammar)->grammar->tree; 26 | 27 | { 28 | package Calc; 29 | 30 | use base 'Pegex::Tree'; 31 | use List::Util qw( reduce ); 32 | use vars qw( $a $b ); # just to suppress a warning in older perls 33 | 34 | sub got_expr { 35 | my ($self, $list) = @_; 36 | my $res = shift @$list; 37 | while (@$list) { 38 | my $op = shift @$list; 39 | my $other = shift @$list; 40 | if ($op eq '+') { 41 | $res += $other; 42 | } else { # $op eq '-' 43 | $res -= $other; 44 | } 45 | } 46 | return $res; 47 | } 48 | 49 | sub got_term { 50 | my ($self, $list) = @_; 51 | my $res = shift @$list; 52 | while (@$list) { 53 | my $op = shift @$list; 54 | my $other = shift @$list; 55 | if ($op eq '*') { 56 | $res *= $other; 57 | } else { # $op eq '/' 58 | $res /= $other; 59 | } 60 | } 61 | return $res; 62 | } 63 | 64 | sub got_factor { 65 | my ($self, $list) = @_; 66 | reduce { $b ** $a } reverse @$list; 67 | } 68 | 69 | sub got_atom { 70 | my ($self, $list) = @_; 71 | ref $list ? $list->[0] : $list; 72 | } 73 | } 74 | 75 | my $input = @ARGV ? shift : do { local $/; <> }; 76 | 77 | my $begin = time; 78 | my $res = pegex($grammar, 'Calc')->parse($input); 79 | my $elapsed = time - $begin; 80 | 81 | printf "Elapsed: %.03f sec.\n", $elapsed; 82 | say "Result: $res", 83 | -------------------------------------------------------------------------------- /calc-RG.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use v5.10.1; 4 | use strict; 5 | use warnings; 6 | 7 | use Time::HiRes qw( time ); 8 | use List::Util qw( reduce ); 9 | 10 | my $parser = do { 11 | use Regexp::Grammars; 12 | 13 | qr{ 14 | 15 | 16 | 17 | 18 | <[term]>+ % <[add_op]> 19 | 34 | 35 | 36 | [-+] 37 | 38 | 39 | <[factor]>+ % <[mul_op]> 40 | 55 | 56 | 57 | [*/] 58 | 59 | 60 | <[atom]>+ % \^ 61 | # 62 | 67 | 68 | 69 | 70 | | \( \) 71 | 72 | 73 | [-+]? \d+ (?:\.\d+)? 74 | } 75 | }; 76 | 77 | my $text = (shift // do { local $/; <> }); 78 | 79 | my $begin = time; 80 | if ($text =~ $parser) { 81 | my $elapsed = time - $begin; 82 | printf "Elapsed: %.03f sec.\n", $elapsed; 83 | 84 | say "Result: $/{expr}"; 85 | 86 | } else { 87 | say {*STDERR} $_ for @!; 88 | } 89 | -------------------------------------------------------------------------------- /calc-Rakudo.p6: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl6 2 | 3 | use v6; 4 | 5 | my grammar Arith { 6 | rule TOP { 7 | | <.ws> { make $.made } 8 | | { self.panic("Bad expression") } 9 | } 10 | 11 | rule expr { 12 | | + % { self.do_calc($/, $, $) } 13 | | { self.panic("Bad expression") } 14 | } 15 | 16 | token add-op { 17 | | < + - > 18 | #| { self.panic($/, "Bad addition/substraction operator") } 19 | } 20 | 21 | rule term { 22 | | + % { make self.do_calc($/, $, $) } 23 | | { self.panic($/, "Bad term") } 24 | } 25 | 26 | token mul-op { 27 | | < * / > 28 | #| { self.panic($/, "Bad multiplication/division operator") } 29 | } 30 | 31 | rule factor { 32 | | + % '^' 33 | { 34 | make [**] map { $_.made }, @; 35 | } 36 | | { self.panic($/, "Bad factor") } 37 | } 38 | 39 | rule atom { 40 | | { make +$ } 41 | | '(' ~ ')' { make $.made } 42 | | { self.panic($/, "Bad atom") } 43 | } 44 | 45 | rule number { 46 | <.sign> ? <.pos-num> 47 | | { self.panic($/, "Bad number") } 48 | } 49 | 50 | token sign { < + - > } 51 | token pos-num { 52 | | <.digit>+ [ \. + ]? 53 | | \. <.digit>+ 54 | | { self.panic($/, "Bad number") } 55 | } 56 | 57 | method do_calc($/, $values, $ops) { 58 | my $res = $values.shift.made; 59 | while ($values.elems) { 60 | my $op = $ops.shift; 61 | my $other = $values.shift.made; 62 | 63 | given $op { 64 | when '+' { $res += $other; } 65 | when '-' { $res -= $other; } 66 | when '*' { $res *= $other; } 67 | default { # when '/' 68 | $res /= $other; 69 | } 70 | } 71 | } 72 | make $res; 73 | } 74 | 75 | method panic($/, $msg) { 76 | my $c = $/.CURSOR; 77 | my $pos := $c.pos; 78 | die "$msg found at pos $pos"; 79 | } 80 | } 81 | 82 | my $input = (@*ARGS[0] // slurp); 83 | 84 | my $begin = now; 85 | try Arith.parse($input); 86 | if $! { 87 | say "Parse failed: ", $!.message; 88 | 89 | } elsif $/ { 90 | my $elapsed = now - $begin; 91 | printf "Elapsed: %.03f sec.\n", $elapsed; 92 | say "Result: ", $(); 93 | 94 | } else { 95 | say "Parse failed."; 96 | } 97 | -------------------------------------------------------------------------------- /calc.fan: -------------------------------------------------------------------------------- 1 | grammar Arith { 2 | expr: 3 | - term(s) % add-op - 4 | 5 | add-op: 6 | /\s* ( [+-] ) \s*/ 7 | 8 | term: factor(s) % mul-op 9 | 10 | mul-op: 11 | /\s* ( [*\/] ) \s*/ 12 | 13 | factor: atom(s) % '^' 14 | 15 | atom: 16 | | number 17 | | '(' expr ')' 18 | 19 | number: 20 | /( -? \d+ (?: \. \d+ )? )/ 21 | } 22 | 23 | class Calc is Actions { 24 | method expr (@terms, @ops) { 25 | my $res = shift @terms; 26 | #my $n = self.get-line; 27 | while @terms { 28 | my $op = shift @ops; 29 | my $other = shift @terms; 30 | 31 | if $op eq '+' { 32 | $res += $other; 33 | } else { 34 | $res -= $other; 35 | } 36 | } 37 | $res; 38 | } 39 | 40 | method term (@factors, @ops) { 41 | my $res = shift @factors; 42 | #my $n = self.get-line; 43 | while @factors { 44 | my $op = shift @ops; 45 | my $other = shift @factors; 46 | 47 | if $op eq '*' { 48 | $res *= $other; 49 | } else { 50 | $res /= $other; 51 | } 52 | } 53 | $res; 54 | } 55 | 56 | method factor (@atoms) { 57 | my $res = pop @atoms; 58 | #my $n = self.get-line; 59 | while @atoms { 60 | $res = @atoms.pop ** $res; 61 | } 62 | $res; 63 | } 64 | } 65 | 66 | # TODO: we could use orelse to connect to the following 67 | # 2 lines once we have it in fanlang. 68 | my $infile = shift @*ARGS; 69 | die "No input file specified.\n" unless defined $infile; 70 | 71 | # TODO: we could use orelse to connect to the following 72 | # 2 lines once we have it in fanlang. 73 | my $input = slurp $infile; 74 | die "failed to read file $infile: $!" unless defined $input; 75 | 76 | my $begin = now; 77 | my $res = Arith.parse: $input, Calc.new; 78 | my $err = $!; 79 | 80 | printf "Elapsed: %.03f sec\n", now - $begin; 81 | 82 | if !defined $res { 83 | die "Failed to parse: $infile", $err // "unknown", "\n"; 84 | } 85 | 86 | say "Result: $res"; 87 | -------------------------------------------------------------------------------- /gen-rand-expr.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use 5.010; 4 | use strict; 5 | use warnings; 6 | 7 | my $count = shift // 1024 * 10; 8 | my $maxnum = 10000; 9 | my @operators = qw( + - * / ); 10 | my @spaces = (' ', "\t", "\n"); 11 | 12 | sub gen_num () { 13 | my $c = int(rand 5) + 1; 14 | my $n = rand($maxnum * 2) - $maxnum; 15 | my $res = (int rand 2) > 0 ? sprintf("%.0${c}f", $n) : 1 + int $n; 16 | if ($res < 0) { 17 | print "($res)"; 18 | } else { 19 | print $res; 20 | } 21 | } 22 | 23 | sub gen_space () { 24 | my $n = int rand 4; 25 | for (my $i = 0; $i < $n; $i++) { 26 | print $spaces[int rand scalar @spaces]; 27 | } 28 | } 29 | 30 | sub gen_op () { 31 | print $operators[int rand scalar @operators]; 32 | } 33 | 34 | gen_space(); 35 | gen_num(); 36 | gen_space(); 37 | 38 | for (my $i = 0; $i < $count; $i++) { 39 | gen_space(); 40 | gen_op(); 41 | gen_space(); 42 | gen_num(); 43 | } 44 | 45 | print "*(5-(3-1)*2^3^4+10)"; 46 | 47 | gen_space(); 48 | -------------------------------------------------------------------------------- /result/ingy-6c31e18-5.20.0: -------------------------------------------------------------------------------- 1 | $ make 2 | Linux think-moar 3.13.0-46-generic #79-Ubuntu SMP Tue Mar 10 20:06:50 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux 3 | sysctl: cannot stat /proc/sys/machdep/cpu/brand_string: No such file or directory 4 | Intel(R) Core(TM) i7-3667U CPU @ 2.00GHz 5 | 6 | === Perl v5.20.0 eval 7 | sed 's/\^/**/g' expr.txt > pl-expr.txt 8 | time perl -e 'my $a = do { local $/; <> }; eval "print q{Result: }, $a, qq{\n}"; die $@ if $@' < pl-expr.txt 9 | Result: 6.48266260706128e+26 10 | 0.03user 0.03system 0:00.07elapsed 92%CPU (0avgtext+0avgdata 2504maxresident)k 11 | 0inputs+0outputs (0major+11824minor)pagefaults 0swaps 12 | 13 | === Perl 5 Pegex 0.60 14 | time perl calc-Pegex.pl < expr.txt 15 | Result: 6.48266260706128e+26 16 | 1.24user 0.03system 0:01.27elapsed 100%CPU (0avgtext+0avgdata 8464maxresident)k 17 | 32inputs+0outputs (1major+13328minor)pagefaults 0swaps 18 | 19 | === Perl 5 Parse::RecDescent 1.967009 20 | time perl calc-PRD.pl < expr.txt 21 | Result: 6.48266260706128e+26 22 | 15.54user 0.14system 0:15.67elapsed 100%CPU (0avgtext+0avgdata 18356maxresident)k 23 | 0inputs+0outputs (0major+64586minor)pagefaults 0swaps 24 | 25 | === Perl 5 Regexp::Grammars 1.039 26 | time perl calc-RG.pl < expr.txt 27 | Result: 6.48266260706128e+26 28 | 4.34user 0.94system 0:05.29elapsed 99%CPU (0avgtext+0avgdata 3141568maxresident)k 29 | 16inputs+0outputs (1major+779478minor)pagefaults 0swaps 30 | 31 | === Perl 6 Rakudo 2014.08 built on MoarVM version 2014.08 32 | time perl6 calc-Rakudo.p6 < expr.txt 33 | Result: 6.48266260706128e+26 34 | 21.21user 0.12system 0:21.50elapsed 99%CPU (0avgtext+0avgdata 224236maxresident)k 35 | 39320inputs+0outputs (4369major+51034minor)pagefaults 0swaps 36 | -------------------------------------------------------------------------------- /result/ingy-8637d9e-5.20.0: -------------------------------------------------------------------------------- 1 | Linux think-moar 3.13.0-46-generic #79-Ubuntu SMP Tue Mar 10 20:06:50 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux 2 | sysctl: cannot stat /proc/sys/machdep/cpu/brand_string: No such file or directory 3 | Intel(R) Core(TM) i7-3667U CPU @ 2.00GHz 4 | 5 | === Perl v5.20.0 eval 6 | sed 's/\^/**/g' expr.txt > pl-expr.txt 7 | time /home/ingy/local/opt/plenv/versions/5.20.0/bin/perl -e 'my $a = do { local $/; <> }; eval "print q{Result: }, $a, qq{\n}"; die $@ if $@' < pl-expr.txt 8 | Result: 6.48266260706128e+26 9 | 0.01user 0.00system 0:00.01elapsed 94%CPU (0avgtext+0avgdata 2504maxresident)k 10 | 0inputs+0outputs (0major+714minor)pagefaults 0swaps 11 | 12 | === Perl 5 Pegex 0.60 13 | time /home/ingy/local/opt/plenv/versions/5.20.0/bin/perl calc-Pegex.pl < expr.txt 14 | Result: 6.48266260706128e+26 15 | 1.21user 0.00system 0:01.21elapsed 99%CPU (0avgtext+0avgdata 8464maxresident)k 16 | 0inputs+0outputs (0major+2221minor)pagefaults 0swaps 17 | 18 | === Perl 5 Parse::RecDescent 1.967009 19 | time /home/ingy/local/opt/plenv/versions/5.20.0/bin/perl calc-PRD.pl < expr.txt 20 | Result: 6.48266260706128e+26 21 | 17.56user 0.05system 0:17.61elapsed 100%CPU (0avgtext+0avgdata 18568maxresident)k 22 | 0inputs+0outputs (0major+38514minor)pagefaults 0swaps 23 | 24 | === Perl 5 Regexp::Grammars 1.039 25 | time /home/ingy/local/opt/plenv/versions/5.20.0/bin/perl calc-RG.pl < expr.txt 26 | Result: 6.48266260706128e+26 27 | 5.04user 0.82system 0:05.87elapsed 99%CPU (0avgtext+0avgdata 3143420maxresident)k 28 | 0inputs+0outputs (0major+686565minor)pagefaults 0swaps 29 | 30 | === Perl 6 Rakudo 2014.08 built on MoarVM version 2014.08 31 | time /home/ingy/bin/perl6 calc-Rakudo.p6 < expr.txt 32 | Result: 6.48266260706128e+26 33 | 21.75user 0.09system 0:21.83elapsed 100%CPU (0avgtext+0avgdata 224092maxresident)k 34 | 0inputs+0outputs (0major+55341minor)pagefaults 0swaps 35 | 36 | --------------------------------------------------------------------------------