Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
timeout.c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
timeout.c
Commits
a605dc78
Commit
a605dc78
authored
Feb 02, 2014
by
william
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add llrb test
parent
cc8d1f97
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
432 additions
and
4 deletions
+432
-4
Makefile
Makefile
+2
-2
bench-llrb.c
bench-llrb.c
+418
-0
bench.c
bench.c
+12
-2
No files found.
Makefile
View file @
a605dc78
all
:
bench bench-wheel.so bench-heap.so
all
:
bench
.so
bench-wheel.so bench-heap.so
WHEEL_BIT
=
6
WHEEL_BIT
=
6
WHEEL_NUM
=
4
WHEEL_NUM
=
4
...
@@ -68,7 +68,7 @@ bench-%.so: bench-%.c timeout.h
...
@@ -68,7 +68,7 @@ bench-%.so: bench-%.c timeout.h
.PHONY
:
clean clean~
.PHONY
:
clean 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
clean~
:
clean
$(RM)
*
~
$(RM)
*
~
bench-llrb.c
0 → 100644
View file @
a605dc78
This diff is collapsed.
Click to expand it.
bench.c
View file @
a605dc78
...
@@ -27,6 +27,13 @@ struct bench {
...
@@ -27,6 +27,13 @@ struct bench {
};
/* 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
)
{
static
int
bench_new
(
lua_State
*
L
)
{
const
char
*
path
=
luaL_checkstring
(
L
,
1
);
const
char
*
path
=
luaL_checkstring
(
L
,
1
);
size_t
count
=
luaL_optlong
(
L
,
2
,
1000000
);
size_t
count
=
luaL_optlong
(
L
,
2
,
1000000
);
...
@@ -89,9 +96,10 @@ static int bench_del(lua_State *L) {
...
@@ -89,9 +96,10 @@ static int bench_del(lua_State *L) {
static
int
bench_fill
(
lua_State
*
L
)
{
static
int
bench_fill
(
lua_State
*
L
)
{
struct
bench
*
B
=
lua_touserdata
(
L
,
1
);
struct
bench
*
B
=
lua_touserdata
(
L
,
1
);
size_t
count
=
luaL_optlong
(
L
,
2
,
B
->
count
);
size_t
i
;
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
);
B
->
ops
.
add
(
B
->
state
,
&
B
->
timeout
[
i
],
random
()
%
B
->
maximum
);
}
}
...
@@ -134,6 +142,7 @@ static const luaL_Reg bench_methods[] = {
...
@@ -134,6 +142,7 @@ static const luaL_Reg bench_methods[] = {
{
"del"
,
&
bench_del
},
{
"del"
,
&
bench_del
},
{
"fill"
,
&
bench_fill
},
{
"fill"
,
&
bench_fill
},
{
"expire"
,
&
bench_expire
},
{
"expire"
,
&
bench_expire
},
{
"close"
,
&
bench__gc
},
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
...
@@ -143,7 +152,8 @@ static const luaL_Reg bench_metatable[] = {
...
@@ -143,7 +152,8 @@ static const luaL_Reg bench_metatable[] = {
};
};
static
const
luaL_Reg
bench_globals
[]
=
{
static
const
luaL_Reg
bench_globals
[]
=
{
{
"new"
,
&
bench_new
},
{
"new"
,
&
bench_new
},
{
"clock"
,
&
bench_clock
},
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment