# New Ticket Created by  arcal0d 
# Please include the string:  [perl #68762]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=68762 >


Hello

totally enthusiastic after Damian talk on perl6 in Switzerland last  
week, I tried this morning, to make a little script.
However, the script was taking age just to count lines.

last rakudo download, on mac OS X

here are 2 code, one in perl6 and perl 5
rakudo
#!/usr/local/parrot_install/bin/perl6

my $n=0;
for  $*IN.lines->$line{
   $n++;
}
say "n=$n";

and the "old" variant
#!/usr/bin/env perl
use strict;
use warnings;

my $n=0;
while (my $line=<STDIN>){
   $n++;
}
print "n=$n\n";


so I made 4 files, with 1, 10, 100 ... 10000  lines (text, approx 100  
char per line)
code timings (with the command) for i in 1 10 100 1000 10000; do echo  
"number of lines=$i"; time ./easy-aligned-p5.pl </tmp/a-$i.txt; done

"user" time is reported, in seconds

nblines perl 5  perl 6  `wc -l`
1               .011    .96             .001
10              .005    1.0             .001
100             .005    1.3             .000
1000    .005    4.4             .001
10000   .015    36              .002

Well, is there a problem here, or just something I have not understood  
(I hoped for ($*IN.lines)->$line wa doing some lazy reading, no?)

Tahnks for al the effort with rakudo which look totally great anyway!
Alex



Go North! Go Wild! Fram!
http://www.framexpeditions.com



Reply via email to