From: ara.t.howard@... Date: 2007-02-02T03:05:09+09:00 Subject: Re: For performance, use Lua On Fri, 2 Feb 2007, William James wrote: > > The results are wrong. 500000.5 is the correct average. And this is slower > than pure interpreted Lua (on a 3.19GHz machine). Try it. > the results are right, my code was wrong. here's the correct translation: harp:~ > cat a.rb require 'narray' time = Time.now max_loop = (ARGV.shift || 20).to_i max_size = (ARGV.shift || 1_000_000).to_i a = NArray.float(max_size).indgen + 1 total = 0 max_loop.times { total += a.mean } p Time.now - time p total, total/max_loop harp:~ > ruby a.rb 0.283084 10000010.0 500000.5 > > So a compiled, very low level, very crude language > (i.e., C) using low-precision math can beat Lua. > Not surprising. > well, as i just showed - the math is not low precision and it's correct. remember lua, ruby, luajit, and ruby extensions are all __exactly__ the same thing, namely very low level very crude c. in all cases the good thing is that it's c that someone else has written. the point is that you need to get into c to go fast and that there's a variety of ways to do it. installing narray is just as good a way to do it as any other. regards. -a -- we can deny everything, except that we have the possibility of being better. simply reflect on that. - the dalai lama