diff options
| author | Giampaolo Rodola <g.rodola@gmail.com> | 2016-10-19 02:26:47 +0200 |
|---|---|---|
| committer | Giampaolo Rodola <g.rodola@gmail.com> | 2016-10-19 02:26:47 +0200 |
| commit | 9873308309d6be23c416af7553b8a3941f379b3b (patch) | |
| tree | 31ae5098dfb3682064976c0aa9615fdfa538a62a /scripts/internal/bench_oneshot.py | |
| parent | ece3a4802f49eb89dd90e67b02e74f847c0c0ce1 (diff) | |
| parent | f923f4522f765152aa67e958b7f053cc7007a119 (diff) | |
| download | psutil-9873308309d6be23c416af7553b8a3941f379b3b.tar.gz | |
merge from oneshot branch
Diffstat (limited to 'scripts/internal/bench_oneshot.py')
| -rwxr-xr-x | scripts/internal/bench_oneshot.py | 76 |
1 files changed, 48 insertions, 28 deletions
diff --git a/scripts/internal/bench_oneshot.py b/scripts/internal/bench_oneshot.py index f2609d2b..2ef21729 100755 --- a/scripts/internal/bench_oneshot.py +++ b/scripts/internal/bench_oneshot.py @@ -18,15 +18,26 @@ import textwrap import psutil -ITERATIONS = 10000 +ITERATIONS = 1000 # The list of Process methods which gets collected in one shot and # as such get advantage of the speedup. +names = [ + 'cpu_times', + 'cpu_percent', + 'memory_info', + 'memory_percent', + 'ppid', + 'parent', +] + +if psutil.POSIX: + names.append('uids') + names.append('username') + if psutil.LINUX: - names = ( - 'cpu_percent', + names += [ 'cpu_times', - 'create_time', 'gids', 'name', 'num_ctx_switches', @@ -35,53 +46,61 @@ if psutil.LINUX: 'status', 'terminal', 'uids', - ) -elif psutil.WINDOWS: - names = ( - 'cpu_affinity', - 'cpu_percent', - 'cpu_times', - 'io_counters', - 'ionice', - 'memory_info', - 'memory_percent', - 'nice', - 'num_handles', - ) + ] elif psutil.BSD: - names = ( - 'cpu_percent', + names = [ 'cpu_times', - 'create_time', 'gids', 'io_counters', 'memory_full_info', 'memory_info', - 'memory_percent', + 'name', 'num_ctx_switches', 'ppid', 'status', 'terminal', 'uids', - ) + ] elif psutil.SUNOS: - names = ( + names += [ 'cmdline', - 'create_time', 'gids', 'memory_full_info', 'memory_info', - 'memory_percent', 'name', 'num_threads', 'ppid', 'status', 'terminal', 'uids', + ] +elif psutil.OSX: + names += [ + 'cpu_times', + 'create_time', + 'gids', + 'memory_info', + 'name', + 'num_ctx_switches', + 'num_threads', + 'ppid', + 'terminal', + 'uids', + ] +elif psutil.WINDOWS: + names = ( + 'cpu_affinity', + 'cpu_percent', + 'cpu_times', + 'io_counters', + 'ionice', + 'memory_info', + 'memory_percent', + 'nice', + 'num_handles', ) -else: - raise RuntimeError("platform %r not supported" % sys.platform) +names = sorted(set(names)) setup = textwrap.dedent(""" from __main__ import names @@ -126,4 +145,5 @@ def main(): print("same speed") -main() +if __name__ == '__main__': + main() |
