when
instead of the single-line modifier form of if
really makes me happy. (Yes, I know when
is available in 5.10, but that's not the idiom I'm comfortable using in Perl 5.)There's only one problem: this isn't actually usable in Rakudo yet. I might have the
$*IN
part incorrect, but I changed it to use a filehandle for input and print out each line of the file it read during the for loop. And when I ran it on the 10 meg data file I needed to analyze, it just sat there. I believe it was probably trying to read the entire file before doing anything with it, as laziness isn't implemented yet. Between that and Rakudo's lack of speed, the script was a no-go, and I ended up rewriting the script in Perl 5.PS Before actually posting this, I actually ran the Perl 6 version to completion and timed it. 88 minutes. That's versus less than a second for the Perl 5 version. In fact, I actually wrote and executed the Perl 5 version in considerably less time than it would have taken to just run the Perl 6 version. Also (as sharp eyes may have noticed), I forgot that spaces in regexes are ignored in Perl 6, so the Perl 6 version was in fact incorrect. Getting a working version would have required at least another 88 minutes of sitting there....
Did you at least find where it was slow? That would be useful information.
ReplyDeleteI'm not sure how to do a proper profile on Perl 6 code, but I'm pretty sure the call to "lines" is taking a relatively huge amount of time before it comes back with anything.
ReplyDeleteSadly Rakudo is not yet to the optimization phase... "Premature optimization is the root of all evil" and all that.
ReplyDeleteI tried doing some file processing in Rakudo the other day with $fh.get() (line-at-a-time), and even then it was fairly slow.
That said, Rakudo Star is planned for release in early 2010 ("Spring"), and speed is a high priority for the release - have a look at the Rakudo ROADMAP doc in docs/ROADMAP in the github repo.