lua-users home
lua-l archive

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


I've added an inplace method creation to the benchmark (.lua attached,
.sh the same).

As expected, it is the fastest of initialization. But I'm surprised
that the object creation is faster than clone. Am I measuring it
wrong?

$ time lua factorybench.lua inplace_init 10000000
        3.37 real         3.28 user         0.02 sys

$ time lua factorybench.lua metatable_init 10000000
       47.65 real        46.96 user         0.18 sys

$ time lua factorybench.lua clone_init 10000000
       47.73 real        47.02 user         0.17 sys

$ time lua factorybench.lua plain_init 10000000
       55.11 real        54.20 user         0.19 sys


$ time lua factorybench.lua metatable_call 10000000
        5.93 real         5.78 user         0.03 sys

$ time lua factorybench.lua plain_call 10000000
       18.43 real        18.24 user         0.06 sys

$ time lua factorybench.lua inplace_call 10000000
       44.74 real        42.27 user         0.30 sys

$ time lua factorybench.lua clone_call 10000000
       67.38 real        64.36 user         0.39 sys

LuaJIT numbers:

$ time luajit -O factorybench.lua inplace_init 10000000
        2.18 real         2.15 user         0.00 sys

$ time luajit -O factorybench.lua clone_init 10000000
       37.31 real        36.69 user         0.17 sys

$ time luajit -O factorybench.lua metatable_init 10000000
       37.63 real        36.64 user         0.19 sys

$ time luajit -O factorybench.lua plain_init 10000000
       48.33 real        47.48 user         0.20 sys


$ time luajit -O factorybench.lua metatable_call 10000000
        3.55 real         3.48 user         0.02 sys

$ time luajit -O factorybench.lua plain_call 10000000
       11.19 real        10.96 user         0.06 sys

$ time luajit -O factorybench.lua inplace_call 10000000
       32.37 real        31.96 user         0.10 sys

$ time luajit -O factorybench.lua clone_call 10000000
       34.51 real        33.65 user         0.17 sys


BTW, my configuration:

Mac Book Pro, 2.4 GHz Core 2 Duo, 2GB RAM, OS X 10.5.4.

$ lua -v
Lua 5.1.3  Copyright (C) 1994-2008 Lua.org, PUC-Rio

$ luajit -v
Lua 5.1.3  Copyright (C) 1994-2008 Lua.org, PUC-Rio
LuaJIT 1.1.4  Copyright (C) 2005-2008 Mike Pall, http://luajit.org/

Alexander.

Attachment: factorybench.lua
Description: Binary data