Skip to content

Instantly share code, notes, and snippets.

@unera
Created November 2, 2017 14:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unera/2ca7d3122c58757cf5dde9a4f61af5dc to your computer and use it in GitHub Desktop.
Save unera/2ca7d3122c58757cf5dde9a4f61af5dc to your computer and use it in GitHub Desktop.
Бенчмарк на запись
#!/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