Commit a605dc78 authored by william's avatar william

add llrb test

parent cc8d1f97
all: bench bench-wheel.so bench-heap.so
all: bench.so bench-wheel.so bench-heap.so
WHEEL_BIT = 6
WHEEL_NUM = 4
......@@ -68,7 +68,7 @@ bench-%.so: bench-%.c timeout.h
.PHONY: clean clean~
clean:
$(RM) -r timeout timeout8 timeout16 timeout32 timeout64 *.dSYM bench *.so *.o
$(RM) -r timeout timeout8 timeout16 timeout32 timeout64 *.dSYM *.so *.o
clean~: clean
$(RM) *~
This diff is collapsed.
......@@ -27,6 +27,13 @@ struct bench {
}; /* struct bench */
static int bench_clock(lua_State *L) {
lua_pushnumber(L, (double)clock() / CLOCKS_PER_SEC);
return 1;
} /* bench_clock() */
static int bench_new(lua_State *L) {
const char *path = luaL_checkstring(L, 1);
size_t count = luaL_optlong(L, 2, 1000000);
......@@ -89,9 +96,10 @@ static int bench_del(lua_State *L) {
static int bench_fill(lua_State *L) {
struct bench *B = lua_touserdata(L, 1);
size_t count = luaL_optlong(L, 2, B->count);
size_t i;
for (i = 0; i < B->count; i++) {
for (i = 0; i < count; i++) {
B->ops.add(B->state, &B->timeout[i], random() % B->maximum);
}
......@@ -134,6 +142,7 @@ static const luaL_Reg bench_methods[] = {
{ "del", &bench_del },
{ "fill", &bench_fill },
{ "expire", &bench_expire },
{ "close", &bench__gc },
{ NULL, NULL }
};
......@@ -143,7 +152,8 @@ static const luaL_Reg bench_metatable[] = {
};
static const luaL_Reg bench_globals[] = {
{ "new", &bench_new },
{ "new", &bench_new },
{ "clock", &bench_clock },
{ NULL, NULL }
};
......
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