On Dec 8, 2006, at 10:18 AM, Norman Palardy wrote:


On Dec 08, 2006, at 9:07 AM, Kem Tekinay wrote:

It started with some friendly ribbing. I have a friend who thinks that the answer to all things is "perl," and he goes on and on about its benefits,
speed, flexibility, etc., etc. Meanwhile, perl code looks to me like
something my cat created when he walked across the keyboard.

Long term maintainability is a big consideration.
I've worked on 2 fairly large projects where Perl was used as a development language where subsequent maintainers have simply rewritten large portions because it was simpler than trying to decipher the code at hand. I know someone will say "Well that's just because you had guys maintaining code that did not know Perl". Fortunately on one it was the same guy about 18 months later and he could not read his own code :)

Perl CAN be used in a nice structured way but that's not the way you usually see it done. It's often the "barfed punctuation on the keyboard" style

Imagine my surprise when it took RB a minute to do what perl did in 15 seconds. I'm not surprised that perl is faster, only HOW much faster it is. My argument was going to be, "see, difference wasn't that much, and RB is
much easier to read," but these results make it no contest.

So my question is: Why is RB so much slower? What is it doing that's making
the difference? And could I do something to close the gap?

I certainly would not have guessed that might be the case.
I'd expect a difference but not 4x slower

How do you evaluate "isNumber" ?
The rest seems pretty straight forward and reasonable
  Try replacing the original line:

If IsNumeric(line) Then

with:

If (Val(line) <> 0) Or (IsNumeric(line)) Then

instead. Val should drop out (with a return value of 0) almost immediately if the string isn't interpretable as a number, and the following "... Or (IsNumeric(line))" catches the case where the numeric value of the line was, in fact, supposed to be 0. You might try the CDbl() function instead of Val() and see if there's any speed difference. If it does turn out that IsNumeric() is your computational bottleneck, then hopefully either Val() or CDbl(), combined with short-circuit If-Then evaluation, should speed up the task a bit. Finally, keep in mind that Perl was SUPPOSED to be designed for text processing; it's likely it contains optimized string manipulation/search code that RB doesn't have (unless you use a plugin, or shell out to sed/awk (under OS X/Linux)...)


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to