diff options
author | Mark Pulford <mark@kyne.com.au> | 2011-05-10 21:50:46 +0930 |
---|---|---|
committer | Mark Pulford <mark@kyne.com.au> | 2011-05-10 21:50:46 +0930 |
commit | c877da6c1f84b19cd2e7e8154b4a0d0e355745a0 (patch) | |
tree | e6a0ae882678bc63d9a970a9b9dac00d14de4d19 | |
parent | a472725b6db0132e06a063f2f67c8a04bf910c60 (diff) | |
download | lua-cjson-c877da6c1f84b19cd2e7e8154b4a0d0e355745a0.tar.gz lua-cjson-c877da6c1f84b19cd2e7e8154b4a0d0e355745a0.tar.bz2 lua-cjson-c877da6c1f84b19cd2e7e8154b4a0d0e355745a0.zip |
Suspend the garbage collector during benchmarks
Suspending GC appears to make the benchmark results more consistent.
-rw-r--r-- | tests/common.lua | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tests/common.lua b/tests/common.lua index d712c83..fd0e805 100644 --- a/tests/common.lua +++ b/tests/common.lua | |||
@@ -128,12 +128,13 @@ end | |||
128 | 128 | ||
129 | function benchmark(tests, iter, rep) | 129 | function benchmark(tests, iter, rep) |
130 | local function bench(func, iter) | 130 | local function bench(func, iter) |
131 | collectgarbage("collect") | 131 | collectgarbage("stop") |
132 | local t = gettimeofday() | 132 | local t = gettimeofday() |
133 | for i = 1, iter do | 133 | for i = 1, iter do |
134 | func(i) | 134 | func(i) |
135 | end | 135 | end |
136 | t = gettimeofday() - t | 136 | t = gettimeofday() - t |
137 | collectgarbage("restart") | ||
137 | return (iter / t) | 138 | return (iter / t) |
138 | end | 139 | end |
139 | 140 | ||