summaryrefslogtreecommitdiff
path: root/scripts/internal/bench_oneshot.py
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2016-10-19 02:26:47 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2016-10-19 02:26:47 +0200
commit9873308309d6be23c416af7553b8a3941f379b3b (patch)
tree31ae5098dfb3682064976c0aa9615fdfa538a62a /scripts/internal/bench_oneshot.py
parentece3a4802f49eb89dd90e67b02e74f847c0c0ce1 (diff)
parentf923f4522f765152aa67e958b7f053cc7007a119 (diff)
downloadpsutil-9873308309d6be23c416af7553b8a3941f379b3b.tar.gz
merge from oneshot branch
Diffstat (limited to 'scripts/internal/bench_oneshot.py')
-rwxr-xr-xscripts/internal/bench_oneshot.py76
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()