diff options
| author | Giampaolo Rodola <g.rodola@gmail.com> | 2016-08-05 18:30:47 -0700 |
|---|---|---|
| committer | Giampaolo Rodola <g.rodola@gmail.com> | 2016-08-05 18:30:47 -0700 |
| commit | 242f5225c4146c834bbf3ec24c11fd7787a1e160 (patch) | |
| tree | 388006046739bce176dce1377e69a52c33133ecc /scripts | |
| parent | 6c5578514f2e4e325a8ed054b598d4e4f9b54bb2 (diff) | |
| download | psutil-242f5225c4146c834bbf3ec24c11fd7787a1e160.tar.gz | |
#799 / windows / cpu_times: add memory_info() support
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/internal/bench_oneshot.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/scripts/internal/bench_oneshot.py b/scripts/internal/bench_oneshot.py index 87e48936..78376ad9 100755 --- a/scripts/internal/bench_oneshot.py +++ b/scripts/internal/bench_oneshot.py @@ -11,6 +11,7 @@ See: https://github.com/giampaolo/psutil/issues/799 """ from __future__ import print_function +import os import sys import time @@ -18,6 +19,12 @@ import psutil ITERATIONS = 1000 +if hasattr(time, 'perf_counter'): + timer = time.perf_counter +elif os.name == 'nt': + timer = time.clock +else: + timer = time.time # The list of Process methods which gets collected in one shot and # as such get advantage of the speedup. @@ -66,6 +73,14 @@ elif psutil.SUNOS: 'terminal', 'uids', ) +elif psutil.WINDOWS: + names = ( + 'cpu_percent', + 'cpu_times', + 'num_handles', + 'memory_info', + 'memory_percent', + ) else: raise RuntimeError("platform %r not supported" % sys.platform) @@ -88,18 +103,18 @@ def main(): print(" " + name) # first "normal" run - t = time.time() + t = timer() for x in range(ITERATIONS): call(funs) - elapsed1 = time.time() - t + elapsed1 = timer() - t print("normal: %.3f secs" % elapsed1) # "one shot" run - t = time.time() + t = timer() for x in range(ITERATIONS): with p.oneshot(): call(funs) - elapsed2 = time.time() - t + elapsed2 = timer() - t print("oneshot: %.3f secs" % elapsed2) # done |
