lua-users home
lua-l archive

Re: [ANN] Lua 5.4.0 (work2) now available

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Quoting tobias@justdreams.de:
Quoting Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>:
The focus of Lua 5.4.0 is performance. We're especially interested in
feedback about its performance but all feedback is welcome. Thanks.
--lhf
I have silly little piece of code I use to compare language performance.
Includes I/O and arrays(table in Lua obviously). When called with 20
iterations Lua 5.4 runs 5.8s vs 7.8s in Lua 5.3. That's quite a
significant performance jump! That is looking awesome!
Here is the code, in case someone is wondering:
#!/usr/bin/env lua
-- based on code by Erik Wrenholt
local BAILOUT = 16
local MAX_ITERATIONS = 1000
local RESOLUTION = 40
local RESFLOAT = 40 / 1.0
local RESLOW = 1-RESOLUTION
local RESHGH = RESOLUTION-2
local write, clock, format = io.write, os.clock, string.format
local iterate = function( x, y )
	local cr = y-0.5
	local zi = 0.0
	local zr = 0.0
	for i = 0, MAX_ITERATIONS do
		local tmp = zr * zi
		local zr2 = zr * zr
		local zi2 = zi * zi
		zr = zr2 - zi2 + cr
		zi = tmp + tmp + x
		--print(zr,zi)
		if (zi2+zr2 > BAILOUT) then
			return ' '
		end
	end
	return '*'
end
local mandelbrot = function( n )
	while n>0 do
		for y = RESLOW, RESHGH do
			local output = { }
			for x = RESLOW, RESHGH do
				output[ x+RESOLUTION ] = iterate( x/RESFLOAT, y/RESFLOAT )
			end
			print( table.concat( output, '' ) );
		end
		n = n-1
	end
end
local n = 1
if arg[1] then
	n = tonumber( arg[ 1 ] )
end
local t = clock()
mandelbrot( n )
print( format( "Lua Time Elapsed %.2f", clock() - t ) )

AltStyle によって変換されたページ (->オリジナル) /