Created
April 13, 2021 16:57
-
-
Save filonenko-mikhail/9a1bc5a9fd02d73b162ace1069d22bd3 to your computer and use it in GitHub Desktop.
test
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
print('Tarantool: ', _TARANTOOL) | |
print('JIT: ', jit.status()) | |
local fiber = require('fiber') | |
local ffi = require('ffi') | |
local c = require('digest').crc32 | |
box.cfg{listen=3301} | |
--ffi.C.crc32_calc = ffi.C.tnt_crc32c | |
local function strcrc32(t) | |
assert(type(t) == 'table', 'Not a table') | |
local co = c.new() | |
for _, v in ipairs(t) do co:update(tostring(v)) end | |
return co:result() | |
end | |
local r = { } | |
local fgc = function(item) | |
for i = 1, 1000 do | |
local k = strcrc32({ '79774120882', 'app4t2' }) | |
if r[k] == nil then | |
r[k] = 1 | |
else | |
r[k] = r[k] + 1 | |
end | |
end | |
end | |
for q=1,1000 do | |
local d = ffi.new('char[1]') | |
ffi.gc(d, fgc) | |
end | |
for u=1,10000 do | |
box.tuple.new{1, 2, 3, 4, 5, 6, 7} | |
end | |
fiber.create(function() | |
while true do | |
collectgarbage('collect') | |
collectgarbage('collect') | |
local k = strcrc32({ '79006904268' }) | |
fiber.sleep(0.0001) | |
end | |
end) | |
require('jit.dump').start('+tbisrmXaT', arg[0]:gsub('.lua', '.dump')) | |
local t = { } | |
local fs = {} | |
for g=1,100 do | |
local f = fiber.create(function() | |
for i = 1, 1e6 do | |
local k = strcrc32({ '79774120882', 'app4t2' }) | |
if t[k] then | |
t[k] = t[k] + 1 | |
else | |
t[k] = 1 | |
end | |
if i % 2000 == 0 then | |
fiber.sleep(0.01) | |
end | |
end | |
end) | |
f:set_joinable(true) | |
table.insert(fs, f) | |
end | |
box.schema.space.create('test'):create_index('pkey') | |
for k=1, 1e6 do | |
box.begin() | |
box.space.test:put{k} | |
box.commit() | |
end | |
for _, f in ipairs(fs) do | |
f:join() | |
end | |
for k, v in pairs(t) do print(k, v) end | |
os.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment