From: Robert Klemme Date: 2003-02-27T19:19:01+09:00 Subject: Re: Ruby Compile-time optimization "Daniel Carrera" schrieb im Newsbeitrag news:20030227072950.GD17232@math.umd.edu... > On Thu, Feb 27, 2003 at 04:18:24PM +0900, Robert wrote: > > ^Hi, > > > > did you do this with a loop body that does really do something? I mean, > > your example is a bit artificial and optimizing this scenario would have not > > much impact for real code, because nobody would repeat a constant operation > > in a loop exept for performance measurements. > > > > You could simply sum up a sequence of random numbers or something similar. > > > > Kind regards > > > > robert > > Correct me if I'm wrong, I very well might be. I think that my example > suggests that Ruby's loops and assignments are not more expensive than > Perl's, but Ruby's Fixnum#+ is. We might infer that this is true for > other arithmetic operations as well. Am I right? When it comes to performance measuring is much better than infering, because experience shows that out intuition about bottlenecks often betrays us. > This is only the most miniscule example of optimization, I know. But I > wonder if we can use traditional optimization techniques to (like constant > folding) to speed up Ruby without significantly altering Ruby's > implementation. I doubt the "significant" for constant folding: Does constant folding really help in many cases? If I use a constant value I will typically assign it to a constant variable and reuse that - at least I think this is a typical way to proceed. But OTOH improving performance of "+" will surely help a lot. > It's just a thought. I don't really know much about the subject. Me either. :-) robert