Commit 114ff796 authored by Robin Obůrka's avatar Robin Obůrka

benchmark: Add some simple benchmark infrastructure

parent 9345dcfa
#!/usr/bin/env python3
import sn
class MyBox(sn.SNPipelineBox):
def process(self, msg_type, payload):
return msg_type, payload
if __name__ == "__main__":
MyBox("benchmark_box").run()
#!/usr/bin/env python3
import time
import zmq
import sn
def main():
ctx = sn.SN(zmq.Context.instance())
s = ctx.get_socket("drain")
start = time.time()
avg_sum = 0
avg_cnt = 0
while True:
msg = s.recv_multipart()
msg_type, payload = sn.parse_msg(msg)
c = payload["counter"]
if (c % 10000) == 0:
time_diff = time.time() - start
start = time.time()
avg_sum += time_diff
avg_cnt += 1
print(c, time_diff, "/", avg_sum/avg_cnt)
if __name__ == "__main__":
main()
#!/usr/bin/env python3
import time
import zmq
import sn
def main():
ctx = sn.SN(zmq.Context.instance())
s = ctx.get_socket("feeder")
start = time.time()
for c in range(100000000000):
if (c % 10000) == 0:
print(c, time.time() - start)
start = time.time()
msg = sn.encode_msg("sentinel/bechmark", {"counter": c})
s.send_multipart(msg)
if __name__ == "__main__":
main()
#!/usr/bin/env python3
import time
import zmq
import sn
def main():
ctx = sn.SN(zmq.Context.instance())
s = ctx.get_socket("mon")
while True:
msg = s.recv_multipart()
msg_type, payload = sn.parse_msg(msg)
if msg_type == "sentinel/monitoring/stats":
print(payload)
if __name__ == "__main__":
main()
#!/bin/sh
SESSION="snbenchmark"
# Kill old session if awaiable
if tmux ls | grep -q "$SESSION"; then
tmux kill-session -t "$SESSION"
fi
# Start session
tmux new-session -d -s "$SESSION"
tmux new-window -t "$SESSION":0
tmux split-window -v -p 80
tmux select-pane -t 2
tmux split-window -v -p 66
tmux select-pane -t 3
tmux split-window -v -p 50
tmux select-pane -t 1
tmux split-window -h
#
## Run all necessary commands
tmux select-pane -t 0
tmux send-keys "tail -f sentinel.log" C-m
tmux select-pane -t 1
tmux send-keys "workon sentinel" C-m
tmux send-keys "./feeder.py --resource 'feeder,connect,PUSH,127.0.0.1,8801' -v" C-m
tmux select-pane -t 2
tmux send-keys "workon sentinel" C-m
tmux send-keys "./drain.py --resource 'drain,bind,PULL,*,8802' -v" C-m
tmux select-pane -t 3
tmux send-keys "workon sentinel" C-m
tmux send-keys "./box.py --resource 'in,bind,PULL,*,8801' --resource 'out,connect,PUSH,127.0.0.1,8802' --resource 'mon,connect,PUSH,127.0.0.1,8803' -v" C-m
tmux select-pane -t 4
tmux send-keys "workon sentinel" C-m
tmux send-keys "./monitoring.py --resource 'mon,bind,PULL,*,8803' -v" C-m
# Attach the session
tmux attach-session -t "$SESSION"
if [ "$1" = "keep" ]; then
exit
fi
tmux kill-session -t "$SESSION"
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