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
aaac5a11
Commit
aaac5a11
authored
Apr 27, 2016
by
Elvis Pranskevichus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add golang echo server
parent
f9aa2e26
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
93 additions
and
30 deletions
+93
-30
Dockerfile
Dockerfile
+5
-1
echo_client
echo_client
+20
-23
run_benchmarks
run_benchmarks
+6
-0
servers/.gitignore
servers/.gitignore
+1
-0
servers/goecho.go
servers/goecho.go
+54
-0
servers/requirements.txt
servers/requirements.txt
+7
-6
No files found.
Dockerfile
View file @
aaac5a11
...
...
@@ -7,22 +7,26 @@ RUN DEBIAN_FRONTEND=noninteractive \
ENV
LANG en_US.UTF-8
ENV
WORKON_HOME /usr/local/python-venvs
ENV
GOMAXPROCS 1
RUN
mkdir
-p
/usr/local/python-venvs
RUN
DEBIAN_FRONTEND
=
noninteractive
\
apt-get update
&&
apt-get
install
-y
\
autoconf automake libtool build-essential
\
python3 python3-pip git nodejs gosu
python3 python3-pip git nodejs go
lang go
su
RUN
pip3
install
vex
RUN
vex
--python
=
python3.5
-m
bench pip
install
-U
pip
RUN
mkdir
-p
/var/lib/cache/pip
ADD
servers /usr/src/servers
RUN
go build /usr/src/servers/goecho.go
RUN
vex bench pip
--cache-dir
=
/var/lib/cache/pip
\
install
-r
/usr/src/servers/requirements.txt
RUN
vex bench pip freeze
-r
/usr/src/servers/requirements.txt
EXPOSE
25000
VOLUME
/var/lib/cache
...
...
echo_client
View file @
aaac5a11
...
...
@@ -42,8 +42,6 @@ if __name__ == '__main__':
help
=
'message size in bytes'
)
parser
.
add_argument
(
'--duration'
,
'-T'
,
default
=
30
,
type
=
int
,
help
=
'duration of test in seconds'
)
parser
.
add_argument
(
'--times'
,
default
=
1
,
type
=
int
,
help
=
'number of times to run the test'
)
parser
.
add_argument
(
'--concurrency'
,
default
=
3
,
type
=
int
,
help
=
'request concurrency'
)
parser
.
add_argument
(
'--timeout'
,
default
=
2
,
type
=
int
,
...
...
@@ -75,7 +73,7 @@ if __name__ == '__main__':
else
:
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
sock
.
settimeout
(
15
)
sock
.
settimeout
(
timeout
/
1000
)
sock
.
connect
(
addr
)
n
=
0
...
...
@@ -102,7 +100,6 @@ if __name__ == '__main__':
return
n
,
latency_stats
,
min_latency
,
max_latency
TIMES
=
args
.
times
N
=
args
.
concurrency
DURATION
=
args
.
duration
...
...
@@ -111,25 +108,25 @@ if __name__ == '__main__':
messages
=
0
latency_stats
=
None
start
=
time
.
monotonic
()
for
_
in
range
(
TIMES
):
with
futures
.
ProcessPoolExecutor
(
max_workers
=
N
)
as
e
:
fs
=
[]
for
_
in
range
(
N
):
fs
.
append
(
e
.
submit
(
run_test
,
start
,
DURATION
))
res
=
futures
.
wait
(
fs
)
for
fut
in
res
.
done
:
t_messages
,
t_latency_stats
,
t_min_latency
,
t_max_latency
=
\
fut
.
result
()
messages
+=
t_messages
if
latency_stats
is
None
:
latency_stats
=
t_latency_stats
else
:
latency_stats
=
np
.
add
(
latency_stats
,
t_latency_stats
)
if
t_max_latency
>
max_latency
:
max_latency
=
t_max_latency
if
t_min_latency
<
min_latency
:
min_latency
=
t_min_latency
with
futures
.
ProcessPoolExecutor
(
max_workers
=
N
)
as
e
:
fs
=
[]
for
_
in
range
(
N
):
fs
.
append
(
e
.
submit
(
run_test
,
start
,
DURATION
))
res
=
futures
.
wait
(
fs
)
for
fut
in
res
.
done
:
t_messages
,
t_latency_stats
,
t_min_latency
,
t_max_latency
=
\
fut
.
result
()
messages
+=
t_messages
if
latency_stats
is
None
:
latency_stats
=
t_latency_stats
else
:
latency_stats
=
np
.
add
(
latency_stats
,
t_latency_stats
)
if
t_max_latency
>
max_latency
:
max_latency
=
t_max_latency
if
t_min_latency
<
min_latency
:
min_latency
=
t_min_latency
end
=
time
.
monotonic
()
...
...
run_benchmarks
View file @
aaac5a11
...
...
@@ -73,6 +73,12 @@ benchmarks = [{
'server'
:
nodejs
+
[
'/usr/src/servers/nodeecho.js'
],
'server_address'
:
tcp_address
,
'client'
:
tcp_client
,
},
{
'name'
:
'tcpecho-golang'
,
'title'
:
'TCP echo server (golang)'
,
'server'
:
[
'/usr/src/servers/goecho'
],
'server_address'
:
tcp_address
,
'client'
:
tcp_client
,
},
{
'name'
:
'tcpecho-asyncio-streams'
,
'title'
:
'TCP echo server (asyncio/streams)'
,
...
...
servers/.gitignore
0 → 100644
View file @
aaac5a11
/goecho
servers/goecho.go
0 → 100644
View file @
aaac5a11
// Taken from https://gist.github.com/paulsmith/775764#file-echo-go
package
main
import
(
"net"
"strconv"
"fmt"
)
const
PORT
=
25000
func
main
()
{
server
,
err
:=
net
.
Listen
(
"tcp"
,
":"
+
strconv
.
Itoa
(
PORT
))
if
server
==
nil
{
panic
(
"couldn't start listening: "
+
err
.
Error
())
}
conns
:=
clientConns
(
server
)
for
{
go
handleConn
(
<-
conns
)
}
}
func
clientConns
(
listener
net
.
Listener
)
chan
net
.
Conn
{
ch
:=
make
(
chan
net
.
Conn
)
i
:=
0
go
func
()
{
for
{
client
,
err
:=
listener
.
Accept
()
if
client
==
nil
{
fmt
.
Printf
(
"couldn't accept: "
+
err
.
Error
())
continue
}
i
++
fmt
.
Printf
(
"%d: %v <-> %v
\n
"
,
i
,
client
.
LocalAddr
(),
client
.
RemoteAddr
())
ch
<-
client
}
}()
return
ch
}
func
handleConn
(
client
net
.
Conn
)
{
buf
:=
make
([]
byte
,
102400
)
for
{
reqLen
,
err
:=
client
.
Read
(
buf
)
if
err
!=
nil
{
break
}
if
reqLen
>
0
{
client
.
Write
(
buf
[
:
reqLen
])
}
}
}
servers/requirements.txt
View file @
aaac5a11
uvloop
curio
aiohttp
httptools
gevent
tornado
curio==0.1
aiohttp==0.21.5
gevent==1.1.1
tornado==4.3
Twisted==16.1.1
httptools==0.0.4
uvloop==0.4.7
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