On 1 October 2013 22:04, Michal Kottman <k0mpjut0r@gmail.com> wrote:
> I will try to compare/benchmark it against other key-value databases with Lua bindings later.
Okay, so a little (extremely) synthetic benchmark on my Core i3 laptop (2.3 GHz) comparing Sophia [1], TokyoCabinet [2] and LevelDB [3] through their respective Lua bindings.
The benchmark consisted of creating a new database, storing values into it, where key and value were the string representation of the index, and then reading all the items. Lua table was included for comparison.
My code for Lua is included, the other libraries have very similar code.
local gettime = require "socket".gettime
local function time(what, N, f)
local start = gettime()
f()
local time = gettime() - start
print(what, N, time, N/time, 'ops')
end
local N = 1000000
local DB = {}
time('Lua W', N, function()
for i=1,N do
local v = tostring(i)
DB[v] = v
end
end)
time('Lua R', N, function()
for i=1,N do
local v = tostring(i)
v = DB[v]
end
end)
The results:
+------------------+-----------+----------+
|1M items | Write ops | Read ops |
+------------------+-----------+----------+
|Lua table | 453647 | 743484 |
|Sophia | 186201 | 363695 |
|TokyoCabinet hash | 425572 | 478859 |
|TokyoCabinet btree| 375870 | 327289 |
|LevelDB | 225549 | 182598 |
+------------------+-----------+----------+
Also interesting is the size of the generated databases:
Sophia - 28,884K
TokyoCabinet hash - 31,772K
TokyoCabine btree - 16,156K
LevelDB - 15,032K
And sizes of the shared libraries used (as compiled by LuaDist):
Sophia - 64K
TokyoCabinet - 412K
LevelDB - 309K
If anyone is interested in more precise measurements (or other key-value databases), please point out how I can improve the methodology, or provide some real-world use cases.