From c5ad026cbe21e1dfe1d189dfd7f7f0751b7dbb75 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sat, 17 Mar 2018 10:06:46 +1300 Subject: bench: Add some very simple manual benchmarking helpers This includes a profiler addon that we might consider for promotion to a builtin down the track. --- test/bench/profiler.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 test/bench/profiler.py (limited to 'test/bench/profiler.py') diff --git a/test/bench/profiler.py b/test/bench/profiler.py new file mode 100644 index 00000000..9072e17d --- /dev/null +++ b/test/bench/profiler.py @@ -0,0 +1,25 @@ +import cProfile +from mitmproxy import ctx + + +class Profile: + """ + A simple profiler addon. + """ + def __init__(self): + self.pr = cProfile.Profile() + + def load(self, loader): + loader.add_option( + "profile_path", + str, + "/tmp/profile", + "Destination for the run profile, saved at exit" + ) + self.pr.enable() + + def done(self): + self.pr.dump_stats(ctx.options.profile_path) + + +addons = [Profile()] \ No newline at end of file -- cgit v1.2.3