[Purdue-pm] Perl 6 reads lines 11.7 times faster

Mark Senn mark at purdue.edu
Sat Oct 22 14:35:50 PDT 2016


I ran the following Perl 5 and Perl 6 programs three times each and
averaged the results.  The Perl 5 program read the one million line file
(each line was 99 x's followed by a newline) 11.7 times faster than the
Perl 6 program.

Perl 5 program:
% perl --version
This is perl 5, version 22, subversion 0 (v5.22.0) built for
x86_64-linux-thread-multi
    my $fn = '/tmp/mark/z';
    open $fh, '<', $fn;
    my $n = 0;
    while (<$fh>)
    {
        $n++;
    }
    print "$n\n";

Perl 6 program:
% perl6 --version
This is Rakudo version 2016.10 built on MoarVM version 2016.10
implementing Perl 6.c.
    my $fn = '/tmp/mark/z';
    my $fh = open $fn, :r;
    my $n = 0;
    for $fh.lines
    {
        $n++;
    }
    say $n;

Perl 6 continues to get faster.  I like it _much_ better than Perl 5.

-mark


More information about the Purdue-pm mailing list