NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
you can always beat bad perl code (Score:2)
No "patterns" in his Java... (Score:1)
His perl is idiomatic (except for the spurious =~'s) and looks just like any novice would have written it.
If I had enough data I might take a crack at unrolling it and making it quicker. Like any "benchmark" though, the code can *always* be manipulated to favor one over the other.
Compiled regexes should do it (Score:1)
Simple first pass at it: using qr//:
MRE2 (Score:2)
This is trivial (Score:2)
--
xoa
Re:This is trivial (Score:1)
But, yeah, much easier to read, much faster to write, and much better.
Hmm. I think I should ask pudge to make <tt> text a different colour.
---ict / Spoon
Re:This is trivial (Score:2)
No it won't. The /o only applies to regexes that are based on variables, as in:
That's the ONLY time that--
xoa
Re:This is trivial (Score:1)
You've got to be kidding (Score:2, Insightful)
What underutilized lacky has enough time to worry about making a program that runs in 283 seconds BUT TAKES 5 MINUTES TO WRITE into a program that runs in 137 seconds BUT TAKES 15-30 minutes to write. If the program could be rewritten so that it runs under 10 seconds (my attention span), THEN the extra effort *might* be worth it. This program is likely to be run from a batch job so that a hyoo-mon isn't likely to be at the terminal waiting for it to finish.
Java cuts into my beer-drinking time.
Uh... (Score:4, Insightful)
(1) The Perl code is really bad. Just replacing the "loop-over-each-line-recompiling-the-regex-each-time" by moving the loop invariant regex to the front of
the while speeds things up.
(2) Using qr speeds things up further.
(3) Moving the sunIPs testing before the fileext
testing speeds things up further.
(4) Inlining the 192. and HTTP speeds things up.
Hey, the Java code inlines those strings.
And after all that is done, we're still comparing apples and oranges: the Java code doesn't do regular expressions. If someone has the time, they might want to ape precisely what the Java code is doing, using index() and so forth, and then measure that.
I hope someone will write a polite expose of all the things that are wrong (*) with this article, and both post it to whatever forum/editors, and the author. Mind, be polite, professional, and helpful.
(*) Let me see...
(a) comparing apples and oranges
(b) the Perl code not published in the article
(c) the Perl code is very bad
(d) the input data not available
I won't comment on the Java code itself, I'll leave that to people who do more Java, except that noting that it inlines the filtering data, as opposed to the Perl code which at least has it cleanly separated into variable.
Reply to This