On Mon, 24 Oct 2016 03:27:55 -0700, tbrowder wrote:
> On Sat Oct 22 04:24:15 2016, tbrowder wrote:
> > See <https://github.com/tbrowder/perl6-read-write-tests> for a suite
> > of tests that show the differences.
> 
> Suite has been updated considerably.

In a benchmark on my local machine, after many improvements, I now see Perl 6 
coming out slightly ahead of Perl 5 when the UTF-8 encoding is being used:

$ time perl6 -e 'my $fh = open "longfile"; my $chars = 0; for $fh.lines { 
$chars = $chars + .chars }; $fh.close; say $chars'
60000000

real    0m1.081s
user    0m1.168s
sys     0m0.032s

$ time perl -e 'open my $fh, "<:encoding(UTF-8)", "longfile"; my $chars = 0; 
while ($_ = <$fh>) { chomp; $chars = $chars + length($_) }; close $fh; print 
"$chars\n"'
60000000

real    0m1.110s
user    0m1.088s
sys     0m0.020s

The situation with ASCII/latin-1 is still not quite so rosy:

$ time perl -e 'open my $fh, "<", "longfile"; my $chars = 0; while ($_ = <$fh>) 
{ chomp; $chars = $chars + length($_) }; close $fh; print "$chars\n"'
60000000

real    0m0.277s
user    0m0.260s
sys     0m0.016s

$ time ./perl6-m -e 'my $fh = open "longfile", :enc<ascii>; my $chars = 0; for 
$fh.lines { $chars = $chars + .chars }; $fh.close; say $chars'
60000000

real    0m0.988s
user    0m1.028s
sys     0m0.068s

Though that's now down to a factor of 3.5x, which is hugely better than the 
factor of 9 or 10 before.

What are the conditions for resolving this issue? Clearly the UTF-8 case is 
good enough because Perl 6 is winning there, but "much slower" is a bit 
subjective, so hard to know when we're there (unless we somehow manage to win 
in the ASCII case too...) :-)

/jnthn

Reply via email to