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/tasks.py | |
parent | 01e2a72ce30f0fbb4a027d3246a8ba16e00ae197 (diff) |
move client responsiveness tests to a subfolder
Diffstat (limited to 'client-responsiveness/toys/tasks.py')
-rw-r--r-- | client-responsiveness/toys/tasks.py | 29 |
1 files changed, 29 insertions, 0 deletions
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)} |