forked from tarantool/cbench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cbench_runner.lua
executable file
·107 lines (92 loc) · 3 KB
/
cbench_runner.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
--- init tarantool db wor tests
if #arg < 1 then
print('Please specify engine [memtx] or [vinyl]')
os.exit(1)
end
local engine = arg[1]
local wal_mode
local count
if engine == 'vinyl' then
if #arg < 2 then
print('Please specify wal_mode [write] or [fsync]')
os.exit(1)
end
wal_mode = arg[2]
count = tonumber(arg[3])
elseif engine == 'memtx' then
wal_mode = 'none'
count = tonumber(arg[2])
end
box.cfg {
memtx_memory = 1024^3,
pid_file = 'tarantool.pid',
wal_mode = wal_mode,
}
local bench = require('cbench')
-- settings
local iterations = 2
if count == nil then
count = 1000000
end
local version = box.info.version
local function urlencode(t)
local result = '?'
for key, val in pairs(t) do
if result ~= '?' then
result = result .. '&'
end
result = result .. key .. '=' .. val
end
return result
end
-- Workloads
local tests = { 'replaces', 'selects', 'selrepl', 'updates', 'deletes' }
local workloads
if engine == 'vinyl' then
workloads = {
{ tests = tests, type = 'tree', parts = { 'unsigned' } },
{ tests = tests, type = 'tree', parts = { 'str' } },
{ tests = tests, type = 'tree', parts = { 'unsigned', 'unsigned' } },
{ tests = tests, type = 'tree', parts = { 'unsigned', 'str' } },
{ tests = tests, type = 'tree', parts = { 'str', 'unsigned' } },
{ tests = tests, type = 'tree', parts = { 'str', 'str' } }
}
end
if engine == 'memtx' then
workloads = {
{ tests = tests, type = 'tree', parts = { 'unsigned' } },
{ tests = tests, type = 'tree', parts = { 'str' } },
{ tests = tests, type = 'tree', parts = { 'unsigned', 'unsigned' } },
{ tests = tests, type = 'tree', parts = { 'unsigned', 'str' } },
{ tests = tests, type = 'tree', parts = { 'str', 'unsigned' } },
{ tests = tests, type = 'tree', parts = { 'str', 'str' } },
{ tests = tests, type = 'hash', parts = { 'unsigned' } },
{ tests = tests, type = 'hash', parts = { 'str' } },
{ tests = tests, type = 'hash', parts = { 'unsigned', 'unsigned' } },
{ tests = tests, type = 'hash', parts = { 'unsigned', 'str' } },
{ tests = tests, type = 'hash', parts = { 'str', 'unsigned' } },
{ tests = tests, type = 'hash', parts = { 'str', 'str' } },
}
end
local function export(name, bench_key, value)
local chart_name = name:gsub(' ', '_'):gsub('+_', ''):lower()
local result = {
name = 'cb.' .. bench_key .. '.' .. chart_name,
param = tostring(math.floor(value)), unit = 'rps',
tab = 'cbench.' .. chart_name, v = version
}
print(urlencode(result))
end
local function run()
local benches = bench.run(workloads, count, iterations, engine)
for _, data in pairs(benches) do
local name = data[1]
local series = data[2]
for _, pair in pairs(series) do
export(name, pair[1], pair[2])
end
end
end
run()
os.exit()
-- vim:ts=4:sw=4:expandtab