Commit 44841540 authored by William Ahern's avatar William Ahern

make benchmark scripts a little easier to hack on

parent 954c0a82
......@@ -4,7 +4,7 @@ WHEEL_BIT = 6
WHEEL_NUM = 4
CPPFLAGS = -DTIMEOUT_DEBUG
CFLAGS = -O2 -g -Wall -Wextra -Wno-unused-parameter
CFLAGS = -O2 -march=native -g -Wall -Wextra -Wno-unused-parameter
timeout: CPPFLAGS+=-DWHEEL_BIT=$(WHEEL_BIT) -DWHEEL_NUM=$(WHEEL_NUM)
......@@ -31,16 +31,20 @@ bench: bench.c timeout.h
ifeq ($(shell uname -s), Darwin)
SOFLAGS = -bundle -undefined dynamic_lookup
else
SOFLAGS = -shared
SOFLAGS = -fPIC -shared
endif
# so bench.so can load implementation module from CWD
LDFLAGS = -Wl,-rpath,.
# clock_gettime in librt.so
ifeq ($(shell uname -s), Linux)
LIBS = -lrt
endif
bench.so: bench.c
$(CC) -o $@ $< $(CPPFLAGS) -DLUA_COMPAT_ALL $(CFLAGS) -Wno-unused-function $(SOFLAGS) $(LIBS)
$(CC) -o $@ $< $(CPPFLAGS) -DLUA_COMPAT_ALL $(CFLAGS) -Wno-unused-function $(SOFLAGS) $(LDFLAGS) $(LIBS)
bench-wheel8.so: CPPFLAGS+=-DWHEEL_BIT=3 -DWHEEL_NUM=$(WHEEL_NUM)
......
#!/usr/bin/env lua
local lib = ... or "bench-wheel.so"
local bench = require"bench"
local aux = require"bench-aux"
local lib = ... or "bench-wheel.so"
local limit = 1000000
local step = limit / 100
local bench = require"bench".new(lib, count)
local clock = require"bench".clock
bench:fill(limit)
local B = bench.new(lib, count)
B:fill(limit)
local n = limit
for i=0,limit,step do
bench:expire(n)
-- expire all timeouts
local expire_t = aux.time(B.expire, B, n)
local start = clock()
bench:fill(i)
-- add i timeouts
local fill_t = aux.time(B.fill, B, i)
n = i
local stop = clock()
print(i, math.floor((stop - start) * 1000000))
aux.say("%i\t%f\t(%f)", i, fill_t, expire_t)
end
local bench = require"bench"
local clock = bench.clock
local aux = {}
local function time_return(begun, ...)
local duration = clock() - begun
return duration, ...
end
function aux.time(f, ...)
local begun = clock()
return time_return(begun, f(...))
end
function aux.say(...)
print(string.format(...))
end
return aux
#!/usr/bin/env lua
local lib = ... or "bench-wheel.so"
local bench = require"bench"
local aux = require"bench-aux"
local lib = ... or "bench-wheel.so"
local limit = 1000000
local step = limit / 100
local bench = require"bench".new(lib, count)
local clock = require"bench".clock
for i=0,limit,step do
bench:fill(i, 60 * 1000000)
local B = bench.new(lib, count)
local start = clock()
bench:del(0, i)
local stop = clock()
for i=0,limit,step do
local fill_t = aux.time(B.fill, B, i, 60 * 1000000)
local del_t = aux.time(B.del, B, 0, i)
print(i, math.floor((stop - start) * 1000000))
aux.say("%i\t%f\t(%f)", i, del_t, fill_t)
end
#!/usr/bin/env lua
local lib = ... or "bench-wheel.so"
local bench = require"bench"
local aux = require"bench-aux"
local lib = ... or "bench-wheel.so"
local limit = 1000000
local step = limit / 100
local bench = require"bench".new(lib, count)
local clock = require"bench".clock
for i=0,limit,step do
bench:fill(i)
local B = require"bench".new(lib, count)
local start = clock()
bench:expire(i)
local stop = clock()
for i=0,limit,step do
local fill_t = aux.time(B.fill, B, i)
local expire_t = aux.time(B.expire, B, i)--, 60000000)
print(i, math.floor((stop - start) * 1000000))
aux.say("%i\t%f\t(%f)", i, expire_t, fill_t)
end
#include <stdlib.h>
#define TIMEOUT_PUBLIC static
#include "timeout.h"
#include "timeout.c"
#include "bench.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment