diff options
author | Georg Brandl <georg@python.org> | 2007-03-29 12:42:16 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2007-03-29 12:42:16 (GMT) |
commit | 7b1be36bb75b6e682a05f45267077f9c6583f680 (patch) | |
tree | c2f9ecfda4f06080981f5612dc1160f890a1c5a9 | |
parent | 65245739956825549bd01b98db42403c515f6995 (diff) | |
download | cpython-7b1be36bb75b6e682a05f45267077f9c6583f680.zip cpython-7b1be36bb75b6e682a05f45267077f9c6583f680.tar.gz cpython-7b1be36bb75b6e682a05f45267077f9c6583f680.tar.bz2 |
In Windows' time.clock(), when QueryPerformanceFrequency() fails,
the C lib's clock() is used, but it must be divided by CLOCKS_PER_SEC
as for the POSIX implementation (thanks to #pypy).
(backport from rev. 54606)
-rw-r--r-- | Modules/timemodule.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c index 444b739..283ab5f 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -175,7 +175,8 @@ time_clock(PyObject *self, PyObject *unused) if (!QueryPerformanceFrequency(&freq) || freq.QuadPart == 0) { /* Unlikely to happen - this works on all intel machines at least! Revert to clock() */ - return PyFloat_FromDouble(clock()); + return PyFloat_FromDouble(((double)clock()) / + CLOCKS_PER_SEC); } divisor = (double)freq.QuadPart; } |