Last active
January 31, 2022 15:26
-
-
Save sharonovd/4811f3349c9b2fe9d487fa81af6e61e3 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env tarantool | |
local net_box = require('net.box') | |
local fiber = require('fiber') | |
local clock = require('clock') | |
local CONN_STRING = 'localhost:3301' -- SET UP CONECTION STRING TO YOUR ROUTER / PLAIN TARANTOOL | |
local WORKER_COUNT = 256 -- SET UP NUMBER OF PARALLEL REQUESTS HERE | |
local conn = assert(net_box.connect(CONN_STRING)) | |
local success_count = 0 | |
local error_count = 0 | |
local fiber_worker = function() | |
while true do | |
local _, err = conn:eval("return true") -- YOU CAN SPECIFY ARGUMENTED CALLS HERE | |
if err ~= nil then error_count = error_count + 1 else success_count = success_count + 1 end | |
end | |
end | |
local workers = {} | |
local start_time = clock.monotonic() | |
for i = 1, WORKER_COUNT do | |
workers[i] = fiber.new(fiber_worker, i) | |
end | |
while true do | |
fiber.sleep(1) | |
local report_message = string.format('Success count is %s in %s seconds, average RPS is %s', | |
success_count, | |
clock.monotonic() - start_time, | |
success_count / (clock.monotonic() - start_time) | |
) | |
print(report_message) | |
print('Error count is ' .. error_count) | |
end | |
-- STOP IT BY CTRL+C |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment