|
1 | 1 | #!/usr/bin/env tarantool
|
2 | 2 |
|
| 3 | +local fio = require('fio') |
| 4 | +local popen = require('popen') |
| 5 | +package.cpath = './?.so;' .. package.cpath |
| 6 | +local memcached = require('memcached') |
| 7 | + |
| 8 | +local port = 11211 |
| 9 | + |
| 10 | +local function run_memtier(instance, memtier_path, proto) |
| 11 | + print(string.format("Run memtier benchmark with protocol '%s'", proto)) |
| 12 | + |
| 13 | + -- TODO: configure memcached protocol |
| 14 | + -- https://github.com/tarantool/memcached/issues/77 |
| 15 | + local memtier_proto = 'memcache_' .. proto |
| 16 | + local memtier_argv = { |
| 17 | + memtier_path, |
| 18 | + '--server=127.0.0.1', |
| 19 | + string.format('--port=%d', port), |
| 20 | + string.format('--protocol=%s', memtier_proto), |
| 21 | + '--threads=20', |
| 22 | + '--test-time=30', |
| 23 | + '--hide-histogram' |
| 24 | + } |
| 25 | + local ph, err = popen.new(memtier_argv, { |
| 26 | + stdout = popen.opts.INHERIT, |
| 27 | + stderr = popen.opts.INHERIT, |
| 28 | + }) |
| 29 | + local res = ph:wait() |
| 30 | + ph:close() |
| 31 | + |
| 32 | + local rc = res.exit_code |
| 33 | + if rc ~= 0 then |
| 34 | + os.exit(rc) |
| 35 | + end |
| 36 | +end |
| 37 | + |
3 | 38 | box.cfg{
|
4 | 39 | wal_mode = 'none',
|
5 | 40 | memtx_memory = 100 * 1024 * 1024,
|
6 |
| - log_nonblock = false, |
| 41 | + log_nonblock = false, |
7 | 42 | }
|
8 | 43 |
|
9 |
| -package.cpath = './?.so;' .. package.cpath |
10 |
| - |
11 |
| -require('memcached').create('memcached', '0.0.0.0:11211', { |
12 |
| - expire_full_scan_time = 120 |
| 44 | +local mc = memcached.create('memcached', |
| 45 | + string.format('0.0.0.0:%d', port), { |
| 46 | + expire_full_scan_time = 120, |
13 | 47 | })
|
14 | 48 |
|
15 |
| --- box.schema.user.grant('guest', 'read,write,execute', 'universe') |
| 49 | +local root = fio.cwd() |
| 50 | +local memtier_path = fio.pathjoin(root, 'test/bench/memtier_benchmark') |
| 51 | + |
| 52 | +run_memtier(mc, memtier_path, 'text') |
| 53 | +run_memtier(mc, memtier_path, 'binary') |
| 54 | + |
| 55 | +mc:stop() |
| 56 | + |
| 57 | +os.exit(0) |
0 commit comments