summaryrefslogtreecommitdiff
path: root/Tools/pybench/clockres.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2017-02-09 16:09:03 +0100
committerNick Coghlan <ncoghlan@gmail.com>2017-02-09 16:09:03 +0100
commit2a1d833d5da7fa7a01a2eef183b0a208ed019427 (patch)
tree8da3ebb695ae55c69d0a58691403fb13d96a9476 /Tools/pybench/clockres.py
parentc6180bb73c8c7c7f9d8ea9816487b710597b6fc1 (diff)
parentbbd3587a29510bd5a318e0a19fc8570c0cd3b622 (diff)
downloadcpython-2a1d833d5da7fa7a01a2eef183b0a208ed019427.tar.gz
Merge issue #26355 fix from 3.6
Diffstat (limited to 'Tools/pybench/clockres.py')
-rw-r--r--Tools/pybench/clockres.py42
1 files changed, 0 insertions, 42 deletions
diff --git a/Tools/pybench/clockres.py b/Tools/pybench/clockres.py
deleted file mode 100644
index d7f1ac8c93..0000000000
--- a/Tools/pybench/clockres.py
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/env python
-
-""" clockres - calculates the resolution in seconds of a given timer.
-
- Copyright (c) 2006, Marc-Andre Lemburg (mal@egenix.com). See the
- documentation for further information on copyrights, or contact
- the author. All Rights Reserved.
-
-"""
-import time
-
-TEST_TIME = 1.0
-
-def clockres(timer):
- d = {}
- wallclock = time.time
- start = wallclock()
- stop = wallclock() + TEST_TIME
- spin_loops = range(1000)
- while 1:
- now = wallclock()
- if now >= stop:
- break
- for i in spin_loops:
- d[timer()] = 1
- values = sorted(d.keys())
- min_diff = TEST_TIME
- for i in range(len(values) - 1):
- diff = values[i+1] - values[i]
- if diff < min_diff:
- min_diff = diff
- return min_diff
-
-if __name__ == '__main__':
- print('Clock resolution of various timer implementations:')
- print('time.clock: %10.3fus' % (clockres(time.clock) * 1e6))
- print('time.time: %10.3fus' % (clockres(time.time) * 1e6))
- try:
- import systimes
- print('systimes.processtime: %10.3fus' % (clockres(systimes.processtime) * 1e6))
- except ImportError:
- pass