lua-users home
lua-l archive

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



The good side for gcc is that it can be cross-compiled on other platforms. In fact, I do most Win32 compilations natively on OS X now. :)

-ak

Thatcher Ulrich kirjoittaa tiistaina, 2. maaliskuuta 2004, kello 04:18:

On Mar 02, 2004 at 10:28 +1030, Peter Loveday wrote:
From my experience gcc (and therefore I assume mingw?) produces far less efficient code than MSVC, or better still, Intel's compiler. I'd prefer to
see this used.

A performance argument begs for a performance measurement.  I tried
lua-5.0.1 on my Windows machine, compiled with mingwin gcc-3.2.3 and
MSVC7, on a couple of (randomly selected) test programs from The Great
Computer Language Shootout.  I pumped up the iteration counts to get
decent timings.  The MSVC7 version of lua was compiled with /O2 (the
default Release flag) and the mingwin version of lua was compiled with
-O2.  Also, the MSVC7 version is compiled as a monolithic .exe, while
the mingwin version is from luacheia, which has lua and lualib as
DLL's.

The results are inconclusive; gcc is faster on one benchmark; MSVC7 is
faster on the other.  Details:

tulrich@tulrich /cygdrive/c/thatcher/lua-5.0.1
$ time ../luacheia/product/lib/lua5.exe hash2.lua # this is mingwin compiled
1 9999 1 9999

real    0m9.777s
user    0m0.031s
sys     0m0.000s

tulrich@tulrich /cygdrive/c/thatcher/lua-5.0.1
$ time lua/Release/lua.exe hash2.lua    # this is MSVC7 compiled
1 9999 1 9999

real    0m9.121s
user    0m0.031s
sys     0m0.000s

tulrich@tulrich /cygdrive/c/thatcher/lua-5.0.1
$ time ../luacheia/product/lib/lua5.exe sieve.lua # this is mingwin compiled
Count: 1028

real    0m3.187s
user    0m0.015s
sys     0m0.000s

tulrich@tulrich /cygdrive/c/thatcher/lua-5.0.1
$ time lua/Release/lua.exe sieve.lua    # this is MSVC7 compiled
Count: 1028

real    0m4.447s
user    0m0.015s
sys     0m0.015s

tulrich@tulrich /cygdrive/c/thatcher/lua-5.0.1
$

---- hash2.lua ----

-- $Id: hash2.lua,v 1.2 2001/01/11 14:52:55 doug Exp $
-- http://www.bagley.org/~doug/shootout/
-- with help from Roberto Ierusalimschy

local n = tonumber((arg and arg[1]) or 1)

local hash1={}
for i=0,1000000 do
    hash1["foo_"..i] = i
end
local hash2={}
for i=1,n do
    for k,v in hash1 do
	hash2[k] = v + (hash2[k] or 0)
    end
end

io.write(string.format("%d %d %d %d\n", hash1["foo_1"], hash1["foo_9999"],
	     hash2["foo_1"], hash2["foo_9999"]))


---- sieve.lua ----

-- $Id: sieve.lua,v 1.10 2001/07/11 17:58:14 doug Exp $
-- http://www.bagley.org/~doug/shootout/
--
-- Roberto Ierusalimschy pointed out the for loop is much
-- faster for our purposes here than using a while loop.

function main(num)
    local flags = {}
    for num=num,1,-1 do
	count = 0
	for i=2,8192 do
	    flags[i] = 1
	end
	for i=2,8192 do
	    if flags[i] == 1 then
	        for k=i+i, 8192, i do
		    flags[k] = 0
		end
	        count = count + 1	
	    end
	end
    end
end

NUM = tonumber((arg and arg[1])) or 1000
count = 0
main(NUM)
io.write("Count: ", count, "\n")

----

--
Thatcher Ulrich
http://tulrich.com