Created
August 4, 2021 15:29
-
-
Save locker/9df4eaaf1bc889b16706640711c946f7 to your computer and use it in GitHub Desktop.
Tarantool net.box benchmark using future:pairs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clock = require('clock') | |
fiber = require('fiber') | |
net_box = require('net.box') | |
jit_p = require('jit.p') | |
cpuprof = require('gperftools.cpu') | |
URI = '127.0.0.1:3301' | |
ITERATIONS = 1000 | |
CONCURRENCY = 2000 | |
function prepare(conn) | |
conn:eval([[ function bench_func(...) return {...} end ]]) | |
end | |
function test(method) | |
local conn = net_box.connect(URI) | |
prepare(conn) | |
local wall_time_start = clock.monotonic() | |
local proc_time_start = clock.proc() | |
for k = 1, ITERATIONS do | |
local futures = {} | |
for i = 1, CONCURRENCY do | |
table.insert(futures, | |
conn:call('bench_func', {1, 2, 3, 'foo', 'bar'}, | |
{is_async = true})) | |
end | |
for i = 1, CONCURRENCY do | |
for _, r in futures[i]:pairs() do | |
assert(#r == 1 and #r[1] == 5) | |
end | |
end | |
end | |
local wall_elapsed = clock.monotonic() - wall_time_start | |
local proc_elapsed = clock.proc() - proc_time_start | |
conn:close() | |
print(string.format('WALL %.3f PROC %.3f KRPS', | |
CONCURRENCY * ITERATIONS / wall_elapsed / 1000, | |
CONCURRENCY * ITERATIONS / proc_elapsed / 1000)) | |
end | |
for i = 1, 5 do test() end | |
os.exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment