From: Mathieu Bouchard Date: 2001-05-06T03:40:55+09:00 Subject: [ruby-talk:14716] Re: Why's Ruby so slow in this case? On Sun, 6 May 2001, David S. wrote: > On Sun, May 06, 2001 at 01:11:24AM +0900, Stefan Matthias Aust wrote: > > 10.58 474.77 109.53 18949 5.78 156.36 Range#each > It seems to me that your code is spending most of its time in the > range loops. I'd try replacing the loops like Yes, it does spend alot of time, but most of it is yielding; only about 10% (109.53) is REALLY spent there (according to this benchmark) > with simpler "while" loops like it's true that "for" and "while" are still faster than method calls with blocks. > I'm guessing Range allocates a new array of indices for each loop. Oh, that reminds me of both Perl and Python, but not of Ruby. I was *very very* pleased when I saw Ruby had Range objects (which do not allocate any kind of Array) matju