diff options
author | Aldo Cortesi <aldo@corte.si> | 2018-03-19 09:39:25 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-19 09:39:25 +1300 |
commit | cba380de807469d4b8ae6b2db6573473b47f3b30 (patch) | |
tree | 9aa095b58d39f727fbaeb76afcaed0737c14ae3b /test/bench/profiler.py | |
parent | caed8e67d1e47f95ed65be5356782d77e40d11f1 (diff) | |
parent | c5ad026cbe21e1dfe1d189dfd7f7f0751b7dbb75 (diff) | |
download | mitmproxy-cba380de807469d4b8ae6b2db6573473b47f3b30.tar.gz mitmproxy-cba380de807469d4b8ae6b2db6573473b47f3b30.tar.bz2 mitmproxy-cba380de807469d4b8ae6b2db6573473b47f3b30.zip |
Merge pull request #2995 from cortesi/bench
bench: Add some very simple manual benchmarking helpers
Diffstat (limited to 'test/bench/profiler.py')
-rw-r--r-- | test/bench/profiler.py | 25 |
1 files changed, 25 insertions, 0 deletions
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 |