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
44841540
Commit
44841540
authored
Feb 22, 2016
by
William Ahern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make benchmark scripts a little easier to hack on
parent
954c0a82
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
56 additions
and
33 deletions
+56
-33
Makefile
Makefile
+7
-3
bench-add.lua
bench-add.lua
+11
-10
bench-aux.lua
bench-aux.lua
+20
-0
bench-del.lua
bench-del.lua
+8
-10
bench-expire.lua
bench-expire.lua
+8
-10
bench-wheel.c
bench-wheel.c
+2
-0
No files found.
Makefile
View file @
44841540
...
...
@@ -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)
$(L
DFLAGS)
$(L
IBS)
bench-wheel8.so
:
CPPFLAGS+=-DWHEEL_BIT=3 -DWHEEL_NUM=$(WHEEL_NUM)
...
...
bench-add.lua
View file @
44841540
#!/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
bench-aux.lua
0 → 100644
View file @
44841540
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
bench-del.lua
View file @
44841540
#!/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
bench-expire.lua
View file @
44841540
#!/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
bench-wheel.c
View file @
44841540
#include <stdlib.h>
#define TIMEOUT_PUBLIC static
#include "timeout.h"
#include "timeout.c"
#include "bench.h"
...
...
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