diff options
author | drebs <drebs@riseup.net> | 2017-11-02 09:28:56 -0200 |
---|---|---|
committer | drebs <drebs@riseup.net> | 2017-11-02 09:28:56 -0200 |
commit | b36ebc87f449af5ad7a677350a3ccfc7d26cfb1e (patch) | |
tree | 6dd6e7a15ace7f7e15815546f43d333f74101050 /client-responsiveness/toys | |
parent | 01e2a72ce30f0fbb4a027d3246a8ba16e00ae197 (diff) |
move client responsiveness tests to a subfolder
Diffstat (limited to 'client-responsiveness/toys')
-rw-r--r-- | client-responsiveness/toys/Makefile | 20 | ||||
-rw-r--r-- | client-responsiveness/toys/perf.py2 | 24 | ||||
-rw-r--r-- | client-responsiveness/toys/perf.pypy | 24 | ||||
-rw-r--r-- | client-responsiveness/toys/server.py | 17 | ||||
-rw-r--r-- | client-responsiveness/toys/server2.py | 20 | ||||
-rw-r--r-- | client-responsiveness/toys/server3.py | 42 | ||||
-rw-r--r-- | client-responsiveness/toys/tasks.py | 29 |
7 files changed, 176 insertions, 0 deletions
diff --git a/client-responsiveness/toys/Makefile b/client-responsiveness/toys/Makefile new file mode 100644 index 0000000..33761a1 --- /dev/null +++ b/client-responsiveness/toys/Makefile @@ -0,0 +1,20 @@ +# Simple PoC toys + +perf: + httperf --server localhost --port 8080 --num-calls 200 --num-conns 20 --uri / + +perf-little: + httperf --server localhost --port 8080 --num-calls 5 --num-conns 20 --uri / + +perf-easy: + httperf --server localhost --port 8080 --num-calls 5 --num-conns 20 --uri /hi + +inline-server: + python server.py + +thread-server: + python server2.py + +ampoule-server: + python server3.py + diff --git a/client-responsiveness/toys/perf.py2 b/client-responsiveness/toys/perf.py2 new file mode 100644 index 0000000..ef2eeb2 --- /dev/null +++ b/client-responsiveness/toys/perf.py2 @@ -0,0 +1,24 @@ +httperf --server localhost --port 8080 --uri --rate 2000 --num-calls 5000 +httperf --client=0/1 --server=localhost --port=8080 --uri=--rate --send-buffer=4096 --recv-buffer=16384 --num-conns=1 --num-calls=5000 +Maximum connect burst length: 0 + +Total: connections 1 requests 5000 replies 5000 test-duration 6.615 s + +Connection rate: 0.2 conn/s (6615.0 ms/conn, <=1 concurrent connections) +Connection time [ms]: min 6615.0 avg 6615.0 max 6615.0 median 6614.5 stddev 0.0 +Connection time [ms]: connect 0.1 +Connection length [replies/conn]: 5000.000 + +Request rate: 755.9 req/s (1.3 ms/req) +Request size [B]: 67.0 + +Reply rate [replies/s]: min 768.0 avg 768.0 max 768.0 stddev 0.0 (1 samples) +Reply time [ms]: response 1.3 transfer 0.0 +Reply size [B]: header 136.0 content 233.0 footer 0.0 (total 369.0) +Reply status: 1xx=0 2xx=0 3xx=0 4xx=5000 5xx=0 + +CPU time [s]: user 4.87 system 1.56 (user 73.7% system 23.6% total 97.3%) +Net I/O: 321.8 KB/s (2.6*10^6 bps) + +Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0 +Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0 diff --git a/client-responsiveness/toys/perf.pypy b/client-responsiveness/toys/perf.pypy new file mode 100644 index 0000000..671cfa2 --- /dev/null +++ b/client-responsiveness/toys/perf.pypy @@ -0,0 +1,24 @@ +httperf --server localhost --port 8080 --uri --rate 2000 --num-calls 5000 +httperf --client=0/1 --server=localhost --port=8080 --uri=--rate --send-buffer=4096 --recv-buffer=16384 --num-conns=1 --num-calls=5000 +Maximum connect burst length: 0 + +Total: connections 1 requests 5000 replies 5000 test-duration 7.649 s + +Connection rate: 0.1 conn/s (7648.8 ms/conn, <=1 concurrent connections) +Connection time [ms]: min 7648.8 avg 7648.8 max 7648.8 median 7648.5 stddev 0.0 +Connection time [ms]: connect 0.1 +Connection length [replies/conn]: 5000.000 + +Request rate: 653.7 req/s (1.5 ms/req) +Request size [B]: 67.0 + +Reply rate [replies/s]: min 574.0 avg 574.0 max 574.0 stddev 0.0 (1 samples) +Reply time [ms]: response 1.5 transfer 0.0 +Reply size [B]: header 136.0 content 233.0 footer 0.0 (total 369.0) +Reply status: 1xx=0 2xx=0 3xx=0 4xx=5000 5xx=0 + +CPU time [s]: user 5.56 system 1.80 (user 72.6% system 23.5% total 96.2%) +Net I/O: 278.3 KB/s (2.3*10^6 bps) + +Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0 +Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0 diff --git a/client-responsiveness/toys/server.py b/client-responsiveness/toys/server.py new file mode 100644 index 0000000..4afa31b --- /dev/null +++ b/client-responsiveness/toys/server.py @@ -0,0 +1,17 @@ +import os +from klein import run, route +import tasks + +FIB = os.environ.get('FIB', tasks.FIB_DEFAULT) + + +@route('/') +def home(request): + return 'answer is >>> %s\n' % tasks.fib(FIB) + +@route('/hi') +def ping(request): + return 'easy!' + +if __name__ == "__main__": + run("localhost", 8080) diff --git a/client-responsiveness/toys/server2.py b/client-responsiveness/toys/server2.py new file mode 100644 index 0000000..268c7c5 --- /dev/null +++ b/client-responsiveness/toys/server2.py @@ -0,0 +1,20 @@ +import os +from klein import run, route +from twisted.internet.threads import deferToThread +import tasks + +FIB = os.environ.get('FIB', tasks.FIB_DEFAULT) + + +@route('/') +def home(request): + d = deferToThread(tasks.fib, FIB) + d.addCallback(lambda result: 'answer is >>> %s\n' % result) + return d + +@route('/hi') +def ping(request): + return 'easy!' + +if __name__ == "__main__": + run("localhost", 8080) diff --git a/client-responsiveness/toys/server3.py b/client-responsiveness/toys/server3.py new file mode 100644 index 0000000..d737d4b --- /dev/null +++ b/client-responsiveness/toys/server3.py @@ -0,0 +1,42 @@ +import os +import sys +from klein import run, route + +from twisted.internet import defer +from twisted.internet import reactor +from twisted.python import log + +from ampoule import pool + +import tasks + +log.startLogging(sys.stdout) + +FIB = os.environ.get('FIB', tasks.FIB_DEFAULT) + + +@route('/') +def home(request): + d = pp.doWork(tasks.Fib, n=int(FIB)) + d.addCallback(lambda res: 'answer is >>> {r}\n'.format(r=res['fib'])) + return d + +@route('/hi') +def ping(request): + return 'easy!' + + +pp = None + + +@defer.inlineCallbacks +def start_pool(): + global pp + # TODO get max number of processors + pp = pool.ProcessPool(tasks.FibCalculator, min=1, max=4) + print 'starting pool' + yield pp.start() + +if __name__ == "__main__": + reactor.callWhenRunning(start_pool) + run("localhost", 8080) diff --git a/client-responsiveness/toys/tasks.py b/client-responsiveness/toys/tasks.py new file mode 100644 index 0000000..3f8b85d --- /dev/null +++ b/client-responsiveness/toys/tasks.py @@ -0,0 +1,29 @@ +import os +from twisted.protocols import amp +from ampoule import child + +FIB_DEFAULT = 30 + + +def fib(n): + '''very silly fibonacci function. + do not try to optimize this, the idea is to make your cpu suffer for a + while''' + n = int(n) + if n <= 2: + return 1 + else: + return fib(n-1) + fib(n-2) + +# ampoule stuff + +class Fib(amp.Command): + arguments = [('n', amp.Integer())] + response = [('fib', amp.Integer())] + + +class FibCalculator(child.AMPChild): + @Fib.responder + def fib(self, n): + #print "FIB FUNCTION CALLED WITH", n + return {"fib": fib(n)} |