From: Dmitry Nikiforov Date: 2012-02-04T02:13:15+09:00 Subject: Re: Basic Ruby performance Robert Klemme wrote in post #1043884: > Question: the data needs to come from somewhere. Are you sure that > your processing is CPU bound? If it is IO bound the difference > between Perl and Ruby won't really show. I reckon it's better to > create a more realistic example of what you are trying to do and > measure again. (And take care to run tests between Ruby and Perl > alternating in order to prevent OS IO caching from preferring one or > the other.) Yep, I'm sure it's CPU bound: the CPU load is at 100%. The data comes in faster than the Ruby script can process it, unfortunately, at this point. I'm trying to optimize it, of course, but so far Perl version beats Ruby hands down. But there aren't too many options at my disposal, it seems. In my examples, the "for" seems to be the major culprit: it alone, without ANYTHING within the loop, takes 19 seconds to execute 1E8 times. The (0..1E8).each only saves about 1 second for me. Which doesn't really matter - most of the loops in my scripts are "while" loops anyway. Still, the regexps themselves run very slow. I wish Ruby used standard Perl's PCRE library - that would make at least regexps run as fast as they do in Perl, and I would be able to write my scripts in Ruby :) -- Posted via http://www.ruby-forum.com/.