aboutsummaryrefslogtreecommitdiffstats
path: root/test/bench
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2018-05-08 14:53:56 +1200
committerGitHub <noreply@github.com>2018-05-08 14:53:56 +1200
commit8a682d3532ec071f20f4ba0f4700fbcdb7921699 (patch)
treecc437a95786c34200340e43e39c145f0c5ea5d25 /test/bench
parent7ec9c5524f64bbceaf52b58696c8c9342a4887dd (diff)
parent717fbaa99076545d11f554187759005dce1aa67b (diff)
downloadmitmproxy-8a682d3532ec071f20f4ba0f4700fbcdb7921699.tar.gz
mitmproxy-8a682d3532ec071f20f4ba0f4700fbcdb7921699.tar.bz2
mitmproxy-8a682d3532ec071f20f4ba0f4700fbcdb7921699.zip
Merge pull request #3105 from cortesi/opts
Add deferred options, tweak benchmarks, document done event
Diffstat (limited to 'test/bench')
-rw-r--r--test/bench/benchmark.py10
-rwxr-xr-xtest/bench/run-mitmdump (renamed from test/bench/run)0
-rwxr-xr-xtest/bench/run-mitmproxy4
3 files changed, 14 insertions, 0 deletions
diff --git a/test/bench/benchmark.py b/test/bench/benchmark.py
index 8d208088..84ec6005 100644
--- a/test/bench/benchmark.py
+++ b/test/bench/benchmark.py
@@ -11,6 +11,15 @@ class Benchmark:
self.pr = cProfile.Profile()
self.started = False
+ self.resps = 0
+ self.reqs = 0
+
+ def request(self, f):
+ self.reqs += 1
+
+ def response(self, f):
+ self.resps += 1
+
async def procs(self):
ctx.log.error("starting benchmark")
backend = await asyncio.create_subprocess_exec("devd", "-q", "-p", "10001", ".")
@@ -23,6 +32,7 @@ class Benchmark:
)
stdout, _ = await traf.communicate()
open(ctx.options.benchmark_save_path + ".bench", mode="wb").write(stdout)
+ ctx.log.error("Proxy saw %s requests, %s responses" % (self.reqs, self.resps))
ctx.log.error(stdout.decode("ascii"))
backend.kill()
ctx.master.shutdown()
diff --git a/test/bench/run b/test/bench/run-mitmdump
index 9925b578..9925b578 100755
--- a/test/bench/run
+++ b/test/bench/run-mitmdump
diff --git a/test/bench/run-mitmproxy b/test/bench/run-mitmproxy
new file mode 100755
index 00000000..4f1f626e
--- /dev/null
+++ b/test/bench/run-mitmproxy
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+mkdir -p results
+mitmproxy -p0 -q --set benchmark_save_path=./results/mitmproxy -s ./benchmark.py \ No newline at end of file