[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Function at line ### has more than 60 upvalues
- From: "Alexander Gladysh" <agladysh@...>
- Date: Fri, 22 Aug 2008 13:48:19 +0400
I have forgot to add the most interesting: the method call time
benchmark. Also I have fixed broken metatable (oops). New benchmark is
attached.
Method call time measurements show that metatable call is (as
expected) a bit slower than all others.
$ time lua factorybench.lua clone_method 10000000
14.51 real 14.36 user 0.04 sys
$ time lua factorybench.lua plain_method 10000000
14.96 real 14.81 user 0.04 sys
$ time lua factorybench.lua inplace_method 10000000
14.96 real 14.80 user 0.05 sys
$ time lua factorybench.lua metatable_method 10000000
16.88 real 16.68 user 0.05 sys
So, if factory is called often, one should use metatable version. If
methods are called often, "plain" version should be used.
Alexander.
P.S. All benchmark results:
$ time lua factorybench.lua inplace_init 10000000
3.28 real 3.24 user 0.01 sys
$ time lua factorybench.lua clone_init 10000000
46.73 real 46.32 user 0.14 sys
$ time lua factorybench.lua metatable_init 10000000
52.93 real 52.50 user 0.17 sys
$ time lua factorybench.lua plain_init 10000000
54.91 real 54.30 user 0.19 sys
$ time lua factorybench.lua metatable_call 10000000
5.83 real 5.78 user 0.02 sys
$ time lua factorybench.lua plain_call 10000000
18.47 real 18.31 user 0.05 sys
$ time lua factorybench.lua inplace_call 10000000
42.26 real 41.88 user 0.13 sys
$ time lua factorybench.lua clone_call 10000000
65.01 real 64.38 user 0.18 sys
$ time lua factorybench.lua clone_method 10000000
14.51 real 14.36 user 0.04 sys
$ time lua factorybench.lua plain_method 10000000
14.96 real 14.81 user 0.04 sys
$ time lua factorybench.lua inplace_method 10000000
14.96 real 14.80 user 0.05 sys
$ time lua factorybench.lua metatable_method 10000000
16.88 real 16.68 user 0.05 sys
$ time luajit -O factorybench.lua inplace_init 10000000
2.18 real 2.16 user 0.00 sys
$ time luajit -O factorybench.lua clone_init 10000000
36.92 real 36.54 user 0.12 sys
$ time luajit -O factorybench.lua metatable_init 10000000
41.47 real 41.21 user 0.14 sys
$ time luajit -O factorybench.lua plain_init 10000000
48.08 real 47.26 user 0.16 sys
$ time luajit -O factorybench.lua metatable_call 10000000
3.47 real 3.43 user 0.01 sys
$ time luajit -O factorybench.lua plain_call 10000000
11.10 real 10.98 user 0.04 sys
$ time luajit -O factorybench.lua inplace_call 10000000
32.07 real 31.81 user 0.10 sys
$ time luajit -O factorybench.lua clone_call 10000000
33.76 real 33.44 user 0.11 sys
$ time luajit -O factorybench.lua clone_method 10000000
1.92 real 1.90 user 0.00 sys
$ time luajit -O factorybench.lua inplace_method 10000000
1.93 real 1.91 user 0.00 sys
$ time luajit -O factorybench.lua plain_method 10000000
1.94 real 1.92 user 0.00 sys
$ time luajit -O factorybench.lua metatable_method 10000000
5.43 real 5.38 user 0.01 sys
Attachment:
factorybench.lua
Description: Binary data