Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
misc
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
misc
Commits
5f8dce5c
Commit
5f8dce5c
authored
Apr 27, 2016
by
Elvis Pranskevichus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parametrize concurrency and payload size levels
parent
026dc173
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
65 deletions
+50
-65
echo_client
echo_client
+22
-21
run_benchmarks
run_benchmarks
+28
-44
No files found.
echo_client
View file @
5f8dce5c
...
@@ -14,6 +14,28 @@ import time
...
@@ -14,6 +14,28 @@ import time
import
numpy
as
np
import
numpy
as
np
def
weighted_quantile
(
values
,
quantiles
,
weights
):
""" Very close to np.percentile, but supports weights.
:param values: np.array with data
:param quantiles: array-like with many quantiles needed,
quantiles should be in [0, 1]!
:param weights: array-like of the same length as `array`
:return: np.array with computed quantiles.
"""
values
=
np
.
array
(
values
)
quantiles
=
np
.
array
(
quantiles
)
weights
=
np
.
array
(
weights
)
assert
np
.
all
(
quantiles
>=
0
)
and
np
.
all
(
quantiles
<=
1
),
\
'quantiles should be in [0, 1]'
weighted_quantiles
=
np
.
cumsum
(
weights
)
-
0.5
*
weights
weighted_quantiles
-=
weighted_quantiles
[
0
]
weighted_quantiles
/=
weighted_quantiles
[
-
1
]
return
np
.
interp
(
quantiles
,
weighted_quantiles
,
values
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--msize'
,
default
=
1000
,
type
=
int
,
parser
.
add_argument
(
'--msize'
,
default
=
1000
,
type
=
int
,
...
@@ -80,27 +102,6 @@ if __name__ == '__main__':
...
@@ -80,27 +102,6 @@ if __name__ == '__main__':
return
n
,
latency_stats
,
min_latency
,
max_latency
return
n
,
latency_stats
,
min_latency
,
max_latency
def
weighted_quantile
(
values
,
quantiles
,
weights
):
""" Very close to np.percentile, but supports weights.
:param values: np.array with data
:param quantiles: array-like with many quantiles needed,
quantiles should be in [0, 1]!
:param weights: array-like of the same length as `array`
:return: np.array with computed quantiles.
"""
values
=
np
.
array
(
values
)
quantiles
=
np
.
array
(
quantiles
)
weights
=
np
.
array
(
weights
)
assert
np
.
all
(
quantiles
>=
0
)
and
np
.
all
(
quantiles
<=
1
),
\
'quantiles should be in [0, 1]'
weighted_quantiles
=
np
.
cumsum
(
weights
)
-
0.5
*
weights
weighted_quantiles
-=
weighted_quantiles
[
0
]
weighted_quantiles
/=
weighted_quantiles
[
-
1
]
return
np
.
interp
(
quantiles
,
weighted_quantiles
,
values
)
TIMES
=
args
.
times
TIMES
=
args
.
times
N
=
args
.
concurrency
N
=
args
.
concurrency
DURATION
=
args
.
duration
DURATION
=
args
.
duration
...
...
run_benchmarks
View file @
5f8dce5c
...
@@ -27,22 +27,7 @@ server_base = ['docker', 'run', '--rm', '-t', '-p', '25000:25000',
...
@@ -27,22 +27,7 @@ server_base = ['docker', 'run', '--rm', '-t', '-p', '25000:25000',
python
=
[
'vex'
,
'bench'
,
'python'
]
python
=
[
'vex'
,
'bench'
,
'python'
]
nodejs
=
[
'nodejs'
]
nodejs
=
[
'nodejs'
]
echo_variations
=
[{
echo_client
=
[
'./echo_client'
,
'--output-format=json'
]
'name'
:
'1kb'
,
'title'
:
'1kb messages, concurrency 4'
,
'args'
:
[
'--msize=1024'
,
'--concurrency=4'
]
},
{
'name'
:
'10kb'
,
'title'
:
'10kb messages, concurrency 4'
,
'args'
:
[
'--msize=10240'
,
'--concurrency=4'
]
},
{
'name'
:
'100kb'
,
'title'
:
'100kb messages, concurrency 4'
,
'args'
:
[
'--msize=102400'
,
'--concurrency=4'
]
}]
echo_client
=
[
'./echo_client'
,
'--concurrency=4'
,
'--output-format=json'
]
echo_warmup
=
[
'--msize=1024'
,
'--concurrency=4'
,
'--duration=5'
]
tcp_address
=
'127.0.0.1:25000'
tcp_address
=
'127.0.0.1:25000'
unix_address
=
'file:{_socket}/server.sock'
.
format
(
_socket
=
_socket
)
unix_address
=
'file:{_socket}/server.sock'
.
format
(
_socket
=
_socket
)
...
@@ -58,32 +43,24 @@ benchmarks = [{
...
@@ -58,32 +43,24 @@ benchmarks = [{
'server'
:
python
+
[
'/usr/src/servers/gevecho.py'
],
'server'
:
python
+
[
'/usr/src/servers/gevecho.py'
],
'server_address'
:
tcp_address
,
'server_address'
:
tcp_address
,
'client'
:
tcp_client
,
'client'
:
tcp_client
,
'warmup'
:
echo_warmup
,
'variations'
:
echo_variations
,
},
{
},
{
'name'
:
'tcpecho-tornado'
,
'name'
:
'tcpecho-tornado'
,
'title'
:
'TCP echo server (tornado)'
,
'title'
:
'TCP echo server (tornado)'
,
'server'
:
python
+
[
'/usr/src/servers/torecho.py'
],
'server'
:
python
+
[
'/usr/src/servers/torecho.py'
],
'server_address'
:
tcp_address
,
'server_address'
:
tcp_address
,
'client'
:
tcp_client
,
'client'
:
tcp_client
,
'warmup'
:
echo_warmup
,
'variations'
:
echo_variations
,
},
{
},
{
'name'
:
'tcpecho-curio'
,
'name'
:
'tcpecho-curio'
,
'title'
:
'TCP echo server (curio)'
,
'title'
:
'TCP echo server (curio)'
,
'server'
:
python
+
[
'/usr/src/servers/curioecho.py'
],
'server'
:
python
+
[
'/usr/src/servers/curioecho.py'
],
'server_address'
:
tcp_address
,
'server_address'
:
tcp_address
,
'client'
:
tcp_client
,
'client'
:
tcp_client
,
'warmup'
:
echo_warmup
,
'variations'
:
echo_variations
,
},
{
},
{
'name'
:
'tcpecho-nodejs'
,
'name'
:
'tcpecho-nodejs'
,
'title'
:
'TCP echo server (nodejs)'
,
'title'
:
'TCP echo server (nodejs)'
,
'server'
:
nodejs
+
[
'/usr/src/servers/nodeecho.js'
],
'server'
:
nodejs
+
[
'/usr/src/servers/nodeecho.js'
],
'server_address'
:
tcp_address
,
'server_address'
:
tcp_address
,
'client'
:
tcp_client
,
'client'
:
tcp_client
,
'warmup'
:
echo_warmup
,
'variations'
:
echo_variations
,
},
{
},
{
'name'
:
'tcpecho-asyncio-stdstreams'
,
'name'
:
'tcpecho-asyncio-stdstreams'
,
'title'
:
'TCP echo server (asyncio/stdstreams)'
,
'title'
:
'TCP echo server (asyncio/stdstreams)'
,
...
@@ -92,8 +69,6 @@ benchmarks = [{
...
@@ -92,8 +69,6 @@ benchmarks = [{
'--streams'
],
'--streams'
],
'server_address'
:
tcp_address
,
'server_address'
:
tcp_address
,
'client'
:
tcp_client
,
'client'
:
tcp_client
,
'warmup'
:
echo_warmup
,
'variations'
:
echo_variations
,
},
{
},
{
'name'
:
'tcpecho-asyncio-minproto'
,
'name'
:
'tcpecho-asyncio-minproto'
,
'title'
:
'TCP echo server (asyncio/minproto)'
,
'title'
:
'TCP echo server (asyncio/minproto)'
,
...
@@ -102,8 +77,6 @@ benchmarks = [{
...
@@ -102,8 +77,6 @@ benchmarks = [{
'--proto'
],
'--proto'
],
'server_address'
:
tcp_address
,
'server_address'
:
tcp_address
,
'client'
:
tcp_client
,
'client'
:
tcp_client
,
'warmup'
:
echo_warmup
,
'variations'
:
echo_variations
,
},
{
},
{
'name'
:
'unixecho-asyncio-stdstreams'
,
'name'
:
'unixecho-asyncio-stdstreams'
,
'title'
:
'Unix socket echo server (asyncio/stdstreams)'
,
'title'
:
'Unix socket echo server (asyncio/stdstreams)'
,
...
@@ -112,8 +85,6 @@ benchmarks = [{
...
@@ -112,8 +85,6 @@ benchmarks = [{
'--streams'
],
'--streams'
],
'server_address'
:
unix_address
,
'server_address'
:
unix_address
,
'client'
:
unix_client
,
'client'
:
unix_client
,
'warmup'
:
echo_warmup
,
'variations'
:
echo_variations
,
},
{
},
{
'name'
:
'unixecho-asyncio-minproto'
,
'name'
:
'unixecho-asyncio-minproto'
,
'title'
:
'Unix socket echo server (asyncio/minproto)'
,
'title'
:
'Unix socket echo server (asyncio/minproto)'
,
...
@@ -122,8 +93,6 @@ benchmarks = [{
...
@@ -122,8 +93,6 @@ benchmarks = [{
'--proto'
],
'--proto'
],
'server_address'
:
unix_address
,
'server_address'
:
unix_address
,
'client'
:
unix_client
,
'client'
:
unix_client
,
'warmup'
:
echo_warmup
,
'variations'
:
echo_variations
,
},
{
},
{
'name'
:
'tcpecho-uvloop-stdstreams'
,
'name'
:
'tcpecho-uvloop-stdstreams'
,
'title'
:
'TCP echo server (uvloop/stdstreams)'
,
'title'
:
'TCP echo server (uvloop/stdstreams)'
,
...
@@ -132,8 +101,6 @@ benchmarks = [{
...
@@ -132,8 +101,6 @@ benchmarks = [{
'--streams'
,
'--uvloop'
],
'--streams'
,
'--uvloop'
],
'server_address'
:
tcp_address
,
'server_address'
:
tcp_address
,
'client'
:
tcp_client
,
'client'
:
tcp_client
,
'warmup'
:
echo_warmup
,
'variations'
:
echo_variations
,
},
{
},
{
'name'
:
'tcpecho-uvloop-minproto'
,
'name'
:
'tcpecho-uvloop-minproto'
,
'title'
:
'TCP echo server (uvloop/minproto)'
,
'title'
:
'TCP echo server (uvloop/minproto)'
,
...
@@ -142,8 +109,6 @@ benchmarks = [{
...
@@ -142,8 +109,6 @@ benchmarks = [{
'--proto'
,
'--uvloop'
],
'--proto'
,
'--uvloop'
],
'server_address'
:
tcp_address
,
'server_address'
:
tcp_address
,
'client'
:
tcp_client
,
'client'
:
tcp_client
,
'warmup'
:
echo_warmup
,
'variations'
:
echo_variations
,
},
{
},
{
'name'
:
'unixecho-uvloop-stdstreams'
,
'name'
:
'unixecho-uvloop-stdstreams'
,
'title'
:
'Unix socket echo server (uvloop/stdstreams)'
,
'title'
:
'Unix socket echo server (uvloop/stdstreams)'
,
...
@@ -152,8 +117,6 @@ benchmarks = [{
...
@@ -152,8 +117,6 @@ benchmarks = [{
'--streams'
,
'--uvloop'
],
'--streams'
,
'--uvloop'
],
'server_address'
:
unix_address
,
'server_address'
:
unix_address
,
'client'
:
unix_client
,
'client'
:
unix_client
,
'warmup'
:
echo_warmup
,
'variations'
:
echo_variations
,
},
{
},
{
'name'
:
'unixecho-uvloop-minproto'
,
'name'
:
'unixecho-uvloop-minproto'
,
'title'
:
'Unix socket echo server (uvloop/minproto)'
,
'title'
:
'Unix socket echo server (uvloop/minproto)'
,
...
@@ -162,8 +125,6 @@ benchmarks = [{
...
@@ -162,8 +125,6 @@ benchmarks = [{
'--proto'
,
'--uvloop'
],
'--proto'
,
'--uvloop'
],
'server_address'
:
unix_address
,
'server_address'
:
unix_address
,
'client'
:
unix_client
,
'client'
:
unix_client
,
'warmup'
:
echo_warmup
,
'variations'
:
echo_variations
,
}]
}]
...
@@ -256,6 +217,13 @@ def main():
...
@@ -256,6 +217,13 @@ def main():
help
=
'duration of each benchmark in seconds'
)
help
=
'duration of each benchmark in seconds'
)
parser
.
add_argument
(
'--benchmarks'
,
type
=
str
,
parser
.
add_argument
(
'--benchmarks'
,
type
=
str
,
help
=
'comma-separated list of benchmarks to run'
)
help
=
'comma-separated list of benchmarks to run'
)
parser
.
add_argument
(
'--concurrency-levels'
,
type
=
int
,
default
=
[
10
],
nargs
=
'+'
,
help
=
'a list of concurrency levels to use'
)
parser
.
add_argument
(
'--payload-size-levels'
,
type
=
int
,
nargs
=
'+'
,
default
=
[
1024
,
10240
,
102400
],
help
=
'comma-separated list of message size levels '
+
'to use (in bytes)'
)
parser
.
add_argument
(
'--save-json'
,
'-J'
,
type
=
str
,
parser
.
add_argument
(
'--save-json'
,
'-J'
,
type
=
str
,
help
=
'path to save benchmark results in JSON format'
)
help
=
'path to save benchmark results in JSON format'
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
...
@@ -270,6 +238,24 @@ def main():
...
@@ -270,6 +238,24 @@ def main():
benchmarks_data
=
[]
benchmarks_data
=
[]
variations
=
[]
for
concurrency
in
sorted
(
args
.
concurrency_levels
):
for
msgsize
in
sorted
(
args
.
payload_size_levels
):
variations
.
append
({
'title'
:
'{}kb messages, concurrency {}'
.
format
(
round
(
msgsize
/
1024
,
1
),
concurrency
),
'args'
:
[
'--msize={}'
.
format
(
msgsize
),
'--concurrency={}'
.
format
(
concurrency
)
]
})
warmup_concurrency
=
max
(
args
.
concurrency_levels
)
warmup
=
[
'--msize=1024'
,
'--duration=5'
,
'--concurrency={}'
.
format
(
warmup_concurrency
)]
for
benchmark
in
benchmarks
:
for
benchmark
in
benchmarks
:
if
benchmark
[
'name'
]
not
in
benchmarks_to_run
:
if
benchmark
[
'name'
]
not
in
benchmarks_to_run
:
continue
continue
...
@@ -285,7 +271,7 @@ def main():
...
@@ -285,7 +271,7 @@ def main():
print
()
print
()
print
(
'Warming up server...'
)
print
(
'Warming up server...'
)
warmup_cmd
=
benchmark
[
'client'
]
+
benchmark
[
'warmup'
]
warmup_cmd
=
benchmark
[
'client'
]
+
warmup
print
(
' '
.
join
(
warmup_cmd
))
print
(
' '
.
join
(
warmup_cmd
))
subprocess
.
check_output
(
warmup_cmd
)
subprocess
.
check_output
(
warmup_cmd
)
print
()
print
()
...
@@ -300,7 +286,7 @@ def main():
...
@@ -300,7 +286,7 @@ def main():
benchmarks_data
.
append
(
benchmark_data
)
benchmarks_data
.
append
(
benchmark_data
)
try
:
try
:
for
variation
in
benchmark
[
'variations'
]
:
for
variation
in
variations
:
title
=
'BENCHMARK: {}'
.
format
(
variation
[
'title'
])
title
=
'BENCHMARK: {}'
.
format
(
variation
[
'title'
])
print
(
title
)
print
(
title
)
print
(
'-'
*
len
(
title
))
print
(
'-'
*
len
(
title
))
...
@@ -327,8 +313,6 @@ def main():
...
@@ -327,8 +313,6 @@ def main():
print
(
output
)
print
(
output
)
data
[
'name'
]
=
variation
[
'name'
]
benchmark_data
[
'variations'
].
append
(
data
)
benchmark_data
[
'variations'
].
append
(
data
)
finally
:
finally
:
kill_server
()
kill_server
()
...
...
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