From: ara.t.howard@... Date: 2007-02-02T03:25:47+09:00 Subject: Re: For performance, use Lua On Fri, 2 Feb 2007, William James wrote: > And this is slower than pure interpreted Lua (on a 3.19GHz machine). Try > it. it isn't on my machine - but perhaps i'm doing something wrong? can you show it? harp:~ > cat a.lua function average( list ) local sum = 0 for i = 1, #list do sum = sum + list[i] end return sum / #list end local max_loop = 20 local max_size = 1e6 time = os.clock() local a = {} for i = 1, max_size do a[i] = i end local total = 0 for i = 1, max_loop do total = total + average( a ) end print( os.clock() - time ) print( total ) print( total/max_loop ) harp:~ > lua a.lua 2.44 10000010 500000.5 harp:~ > luac a.lua && lua luac.out 2.47 10000010 500000.5 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.287334 10000010.0 500000.5 regards. -a -- we can deny everything, except that we have the possibility of being better. simply reflect on that. - the dalai lama