forked from tarantool/cbench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bench-cfg.lua
executable file
·63 lines (53 loc) · 1.81 KB
/
bench-cfg.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
#!/usr/bin/env tarantool
if #arg < 1 then
print('Please specify engine [memtx] or [vinyl]')
os.exit(1)
end
local engine = arg[1]
if engine == 'vinyl' and #arg < 2 then
print('Please specify wal_mode [write] or [fsync]')
os.exit(1)
end
local wal_mode = arg[2]
box.cfg {
memtx_memory = 1024^3,
pid_file = "tarantool.pid",
wal_mode = wal_mode,
}
-- Tests to run
tests = {'replaces', 'selects', 'selrepl', 'updates', 'deletes'}
-- Workloads
workloads = {
-- Run one extra test to warm up the server
{tests = tests, type = 'hash', parts = { 'unsigned'}},
{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' }},
{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' }}
--]]
}
local bench = require('cbench')
local json = require('json')
print('Benchmarking...')
-- Run benchmark
result = bench.run(workloads, 1000000, 5, engine);
print('Done')
-- Encode the result and save to a file
json_result = json.encode(result)
filename = string.format('bench-result-%s.json',
box.info.version);
file = io.open(filename, 'w')
file:write(json_result)
file:flush()
file:close()
print('Benchmark result saved to ', filename)
os.exit(0)