diff options
| author | Giampaolo Rodola <g.rodola@gmail.com> | 2016-10-27 14:09:16 +0200 |
|---|---|---|
| committer | Giampaolo Rodola <g.rodola@gmail.com> | 2016-10-27 14:09:16 +0200 |
| commit | 7ad634a34da12325b70f07d2a2c6447f402cbf3e (patch) | |
| tree | 1813cbb86c387e1d96aa399580bf635fdae2c4dc /scripts | |
| parent | bd0bbddc3b504297a8701e9a8b4c27d46e83321d (diff) | |
| download | psutil-7ad634a34da12325b70f07d2a2c6447f402cbf3e.tar.gz | |
adjust bench2 script to new perf API
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/internal/bench_oneshot_2.py | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/scripts/internal/bench_oneshot_2.py b/scripts/internal/bench_oneshot_2.py index 61399724..c751a585 100644 --- a/scripts/internal/bench_oneshot_2.py +++ b/scripts/internal/bench_oneshot_2.py @@ -11,7 +11,7 @@ supposed to be more precise. import sys -from perf import Runner +import perf # requires "pip install perf" import psutil from bench_oneshot import names @@ -21,25 +21,23 @@ p = psutil.Process() funs = [getattr(p, n) for n in names] -def call_normal(funs): +def call_normal(): for fun in funs: fun() -def call_oneshot(funs): +def call_oneshot(): with p.oneshot(): for fun in funs: fun() -def prepare_cmd(runner, cmd): - cmd.append(runner.args.benchmark) +def add_cmdline_args(cmd, args): + cmd.append(args.benchmark) def main(): - runner = Runner() - runner.argparser.add_argument('benchmark', choices=('normal', 'oneshot')) - runner.prepare_subprocess_args = prepare_cmd + runner = perf.Runner() args = runner.parse_args() if not args.worker: @@ -48,10 +46,8 @@ def main(): for name in sorted(names): print(" " + name) - if args.benchmark == 'normal': - runner.bench_func("normal", call_normal, funs) - else: - runner.bench_func("oneshot", call_oneshot, funs) + runner.bench_func("normal", call_normal) + runner.bench_func("oneshot", call_oneshot) main() |
