Lua2011. 6. 26. 14:07
 단순 비교.조건 분기 코드를 테스트해 보았다. 물론 리눅스/하드웨어 사양은 전과 동일했다. 테스트 반복 횟수는 5백만번이었다.

 local function cond1(a,b)
    if  ( a > b ) then
        return a
    else
        return b
    end
end

local function test_condition ()
    local max_repeat = 1000 * 1000 * 50
    local x = os.clock()
    local s = 0
    for i = 1 , max_repeat do
        s = cond1( 1, 2 )
    end
    print(string.format(
        "elapsed time: %.9f\tcount = %u\n",
            os.clock() - x ,
            max_repeat ) )
end

test_condition ()


 # lua t1.lua
elapsed time: 17.900000000    count = 50000000

# luajit -j on t1.lua
elapsed time: 0.080000000    count = 50000000


 인터프리터 방식과 jit 사용은 당연히 비교가 안되었으며, 약 200배 정도의 차이가 발생한 듯하다. 물론 c 나  pascal 등 으로 이를 개발하면 거의 0 초 수준이지만... 소스 코드에서 바로 작업한 수준이 이정도인건 훌륭하다!!

반응형

'Lua' 카테고리의 다른 글

Jit compiler 테스트 중…  (0) 2011.07.02
luajit 테스트 - (1)  (0) 2011.06.26
[luajit] LUA + JIT  (0) 2010.12.08
[lua2exe] lua 로 exe 먼들기  (0) 2008.04.24
Posted by Jay Two