Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79308 > unrolled thread
| Started by | Florian Lindner <mailinglists@xgm.de> |
|---|---|
| First post | 2014-10-20 09:47 +0200 |
| Last post | 2014-10-20 09:47 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
time.perf_counter in Python 2? Florian Lindner <mailinglists@xgm.de> - 2014-10-20 09:47 +0200
| From | Florian Lindner <mailinglists@xgm.de> |
|---|---|
| Date | 2014-10-20 09:47 +0200 |
| Subject | time.perf_counter in Python 2? |
| Message-ID | <mailman.14993.1413791277.18130.python-list@python.org> |
Hello, I wrote a script that does some time measurements. It uses time.perf_counter() from Python 3 which works very well. Now I need to backport it to python 2. Docs say that time.clock() is way to go: time.clock() On Unix, return the current processor time as a floating point number expressed in seconds. The precision, and in fact the very definition of the meaning of “processor time”, depends on that of the C function of the same name, but in any case, this is the function to use for benchmarking Python or timing algorithms. On Windows, this function returns wall-clock seconds elapsed since the first call to this function, as a floating point number, based on the Win32 function QueryPerformanceCounter(). The resolution is typically better than one microsecond. But for me it always returns the almost same number, nothing time like: Python 2.7.3 (default, Feb 27 2014, 19:58:35) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import time >>> time.clock() 0.03 >>> time.clock() 0.03 >>> time.clock() 0.04 >>> time.clock() 0.04 What's wrong there? Thanks, Florian
Back to top | Article view | comp.lang.python
csiph-web