From 0f8e8ee1ad667c8d747d5876f9b630ecbc01d7e9 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Sun, 31 May 2015 01:51:13 +0200 Subject: add bench tool for windows --- test/tools/ab.exe | Bin 0 -> 82944 bytes test/tools/benchtool.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++ test/tools/yappibench.py | 51 ----------------------------------------------- 3 files changed, 51 insertions(+), 51 deletions(-) create mode 100644 test/tools/ab.exe create mode 100644 test/tools/benchtool.py delete mode 100644 test/tools/yappibench.py diff --git a/test/tools/ab.exe b/test/tools/ab.exe new file mode 100644 index 00000000..d68ed0f3 Binary files /dev/null and b/test/tools/ab.exe differ diff --git a/test/tools/benchtool.py b/test/tools/benchtool.py new file mode 100644 index 00000000..5cfcba30 --- /dev/null +++ b/test/tools/benchtool.py @@ -0,0 +1,51 @@ +# Profile mitmdump with apachebench and +# yappi (https://code.google.com/p/yappi/) +# +# Requirements: +# - Apache Bench "ab" binary +# - pip install click yappi + +from libmproxy.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(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)) + +@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(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 diff --git a/test/tools/yappibench.py b/test/tools/yappibench.py deleted file mode 100644 index b9e4e41d..00000000 --- a/test/tools/yappibench.py +++ /dev/null @@ -1,51 +0,0 @@ -# Profile mitmdump with apachebench and -# yappi (https://code.google.com/p/yappi/) -# -# Requirements: -# - Apache Bench "ab" binary -# - pip install click yappi - -from libmproxy.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(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)) - -@click.command() -@click.option('--profiler', default="yappi", type=click.Choice(['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(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 -- cgit v1.2.3