Skip to content

Instantly share code, notes, and snippets.

@unera

unera/bench.lua

Created Nov 2, 2017
Embed
What would you like to do?
Бенчмарк на запись
#!/usr/bin/tarantool
local log = require 'log'
local digest = require 'digest'
local fiber = require 'fiber'
box.cfg{ slab_alloc_arena = 1.2, wal_mode = 'fsync' }
local id = 0
function next_id()
id = tonumber64(id) + tonumber64(1)
return id
end
local space = string.format("tst_%s", fiber.time64())
log.info("Creating space %s", space)
box.schema.space.create(space, { engine = 'memtx' })
space = box.space[space]
space:create_index('pk', { parts = { 1, 'unsigned' } })
for i = 1, 200 do
fiber.create(
function()
while(true) do
local tuple = { next_id(),
"01234567890123456789" ..
"xxxxxxxxxxxxxxxxxxxx" ..
"xxxxxxxxxxxxxxxxxxxx" ..
"xxxxxxxxxxxxxxxxxxxx" ..
"xxxxxxxxxxxxxxxxxxxx" ..
"xxxxxxxxxxxxxxxxxxxx" ..
"xxxxxxxxxxxxxxxxxxxx" ..
"xxxxxxxxxxxxxxxxxxxx" ..
"xxxxxxxxxxxxxxxxxxxx" ..
"xxxxxxxxxxxxxxxxxxxx" ..
"xxxxxxxxxxxxxxxxxxxx"
}
space:insert(tuple)
end
end
)
end
local started = fiber.time()
local idstarted = id
while true do
fiber.sleep(0.5)
local delay = fiber.time() - started
log.info('RPS: %s', (id - idstarted) * 1.0 / delay)
idstarted = id
started = fiber.time()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment