diff options
author | Amber Brown <hawkowl@atleastfornow.net> | 2020-04-04 02:31:52 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-03 16:31:52 +0100 |
commit | 334bfdbc9088cfe2fbe43cfe1c349c27734bb341 (patch) | |
tree | 4bd395f26df1e3b59c4ef396ed82ef30605e8f74 /synmark/__main__.py | |
parent | Convert http.HTTPStatus objects to their int equivalent (#7188) (diff) | |
download | synapse-334bfdbc9088cfe2fbe43cfe1c349c27734bb341.tar.xz |
Add some benchmarks for LruCache (#6446)
Diffstat (limited to 'synmark/__main__.py')
-rw-r--r-- | synmark/__main__.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/synmark/__main__.py b/synmark/__main__.py index ac59befbd4..17df9ddeb7 100644 --- a/synmark/__main__.py +++ b/synmark/__main__.py @@ -14,6 +14,7 @@ # limitations under the License. import sys +from argparse import REMAINDER from contextlib import redirect_stderr from io import StringIO @@ -21,7 +22,7 @@ import pyperf from synmark import make_reactor from synmark.suites import SUITES -from twisted.internet.defer import ensureDeferred +from twisted.internet.defer import Deferred, ensureDeferred from twisted.logger import globalLogBeginner, textFileLogObserver from twisted.python.failure import Failure @@ -40,7 +41,8 @@ def make_test(main): file_out = StringIO() with redirect_stderr(file_out): - d = ensureDeferred(main(reactor, loops)) + d = Deferred() + d.addCallback(lambda _: ensureDeferred(main(reactor, loops))) def on_done(_): if isinstance(_, Failure): @@ -50,6 +52,7 @@ def make_test(main): return _ d.addBoth(on_done) + reactor.callWhenRunning(lambda: d.callback(True)) reactor.run() return d.result @@ -62,11 +65,13 @@ if __name__ == "__main__": def add_cmdline_args(cmd, args): if args.log: cmd.extend(["--log"]) + cmd.extend(args.tests) runner = pyperf.Runner( - processes=3, min_time=2, show_name=True, add_cmdline_args=add_cmdline_args + processes=3, min_time=1.5, show_name=True, add_cmdline_args=add_cmdline_args ) runner.argparser.add_argument("--log", action="store_true") + runner.argparser.add_argument("tests", nargs=REMAINDER) runner.parse_args() orig_loops = runner.args.loops @@ -79,6 +84,11 @@ if __name__ == "__main__": ) setupdb() + if runner.args.tests: + SUITES = list( + filter(lambda x: x[0].__name__.split(".")[-1] in runner.args.tests, SUITES) + ) + for suite, loops in SUITES: if loops: runner.args.loops = loops |