Skip to content

Instantly share code, notes, and snippets.

@igormunkin
Last active September 7, 2020 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igormunkin/7e0cf48005bd003ffbdf30181eedb40e to your computer and use it in GitHub Desktop.
Save igormunkin/7e0cf48005bd003ffbdf30181eedb40e to your computer and use it in GitHub Desktop.
gh-1700
local fiber = require('fiber')
local clock = require('clock')
local fibers, iterations = (tonumber(arg[1]) or 1e1), (tonumber(arg[2]) or 1e4)
io.write(("#1700 bench: fibers: %d; iterations: %d"):format(fibers, iterations))
local GLOBAL = fibers
local f = { }
for i = 1, fibers do
f[i] = fiber.new(function(id, iterations)
for i = 1, iterations do fiber.yield() end
GLOBAL = GLOBAL - 1
end, i, iterations)
end
local start = clock.time64()
while GLOBAL > 0 do fiber.yield() end
local stop = clock.time64()
io.write((" => %f sec\n"):format(tonumber(stop - start) / 1e9))
os.exit(0)
#!/bin/sh
TARANTOOL=${1:-./src/tarantool}
RUNS=${2:-15}
BENCHD=bench.d
if [ -d $BENCHD ]; then
echo "$BENCHD is in $(pwd)"
exit 1;
fi
mkdir -p $BENCHD
$TARANTOOL -v | head -1 | tee $BENCHD/tarantool.version
for i in $(seq 1 $RUNS)
do
echo "Run #$i" > $BENCHD/bench.$i
echo -n "Run #$i: ["
for fibers in 10 100 1000 10000
do
for iterations in 100 1000 10000 100000
do
echo -n "*"
taskset -a 0x10 $TARANTOOL bench.lua $fibers $iterations &>> $BENCHD/bench.$i
done
done
echo "]"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment