diff options
author | Aldo Cortesi <aldo@corte.si> | 2018-04-07 09:54:37 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@corte.si> | 2018-04-16 09:20:22 +1200 |
commit | 850c855495d29f24e3c51af582b6b4448433ae69 (patch) | |
tree | 84c7db53b62b36c0a011328178fcaf81160df574 /test/helper_tools/benchtool.py | |
parent | b663a224a3655aab95a39eab2450f1f0e98997f2 (diff) | |
download | mitmproxy-850c855495d29f24e3c51af582b6b4448433ae69.tar.gz mitmproxy-850c855495d29f24e3c51af582b6b4448433ae69.tar.bz2 mitmproxy-850c855495d29f24e3c51af582b6b4448433ae69.zip |
Clean up test/helper_tools directory
Diffstat (limited to 'test/helper_tools/benchtool.py')
-rw-r--r-- | test/helper_tools/benchtool.py | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/test/helper_tools/benchtool.py b/test/helper_tools/benchtool.py deleted file mode 100644 index b9078d0e..00000000 --- a/test/helper_tools/benchtool.py +++ /dev/null @@ -1,56 +0,0 @@ -# Profile mitmdump with apachebench and -# yappi (https://code.google.com/p/yappi/) -# -# Requirements: -# - Apache Bench "ab" binary -# - pip install click yappi - -from mitmproxy.main import mitmdump -from os import system -from threading import Thread -import time - -import yappi -import click - - -class ApacheBenchThread(Thread): - - def __init__(self, concurrency): - self.concurrency = concurrency - super().__init__() - - 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'])) -@click.option('--clock-type', default="cpu", type=click.Choice(['wall', 'cpu'])) -@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(addons=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() |