aboutsummaryrefslogtreecommitdiffstats
path: root/test/tools/benchtool.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2015-05-31 01:51:31 +0200
committerMaximilian Hils <git@maximilianhils.com>2015-05-31 01:51:31 +0200
commitec92fca8c030fe5971a034a658033f70965b990a (patch)
treeef9a2049eeab539d13e1f9662fd51220ab4ee817 /test/tools/benchtool.py
parent0f8e8ee1ad667c8d747d5876f9b630ecbc01d7e9 (diff)
parenta05a70d8168a07c92b2a3ecbbb1958d85532efe3 (diff)
downloadmitmproxy-ec92fca8c030fe5971a034a658033f70965b990a.tar.gz
mitmproxy-ec92fca8c030fe5971a034a658033f70965b990a.tar.bz2
mitmproxy-ec92fca8c030fe5971a034a658033f70965b990a.zip
Merge branch 'master' of github.com:mitmproxy/mitmproxy
Diffstat (limited to 'test/tools/benchtool.py')
-rw-r--r--test/tools/benchtool.py55
1 files changed, 29 insertions, 26 deletions
diff --git a/test/tools/benchtool.py b/test/tools/benchtool.py
index 5cfcba30..ae4636a7 100644
--- a/test/tools/benchtool.py
+++ b/test/tools/benchtool.py
@@ -2,7 +2,7 @@
# yappi (https://code.google.com/p/yappi/)
#
# Requirements:
-# - Apache Bench "ab" binary
+# - Apache Bench "ab" binary
# - pip install click yappi
from libmproxy.main import mitmdump
@@ -13,14 +13,17 @@ import time
import yappi
import click
+
class ApacheBenchThread(Thread):
- def __init__(self, concurrency):
- self.concurrency = concurrency
- super(ApacheBenchThread, self).__init__()
+ def __init__(self, concurrency):
+ self.concurrency = concurrency
+ super(ApacheBenchThread, self).__init__()
+
+ def run(self):
+ time.sleep(2)
+ system(
+ "ab -n 1024 -c {} -X 127.0.0.1:8080 http://example.com/".format(self.concurrency))
- def run(self):
- time.sleep(2)
- system("ab -n 1024 -c {} -X 127.0.0.1:8080 http://example.com/".format(self.concurrency))
@click.command()
@click.option('--profiler', default="none", type=click.Choice(['none', 'yappi']))
@@ -28,24 +31,24 @@ class ApacheBenchThread(Thread):
@click.option('--concurrency', default=1, type=click.INT)
def main(profiler, clock_type, concurrency):
- outfile = "callgrind.mitmdump-{}-c{}".format(clock_type, concurrency)
- a = ApacheBenchThread(concurrency)
- a.start()
-
- if profiler == "yappi":
- yappi.set_clock_type(clock_type)
- yappi.start(builtins=True)
-
- print("Start mitmdump...")
- mitmdump(["-k","-q","-S", "1024example"])
- print("mitmdump stopped.")
-
- print("Save profile information...")
- if profiler == "yappi":
- yappi.stop()
- stats = yappi.get_func_stats()
- stats.save(outfile, type='callgrind')
- print("Done.")
+ outfile = "callgrind.mitmdump-{}-c{}".format(clock_type, concurrency)
+ a = ApacheBenchThread(concurrency)
+ a.start()
+
+ if profiler == "yappi":
+ yappi.set_clock_type(clock_type)
+ yappi.start(builtins=True)
+
+ print("Start mitmdump...")
+ mitmdump(["-k", "-q", "-S", "1024example"])
+ print("mitmdump stopped.")
+
+ print("Save profile information...")
+ if profiler == "yappi":
+ yappi.stop()
+ stats = yappi.get_func_stats()
+ stats.save(outfile, type='callgrind')
+ print("Done.")
if __name__ == '__main__':
- main() \ No newline at end of file
+ main()