From: Georg Brandl Date: Thu, 29 Mar 2007 12:42:07 +0000 (+0000) Subject: In Windows' time.clock(), when QueryPerformanceFrequency() fails, X-Git-Tag: v2.6a1~1917 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=30712ab82f7c545cfe89ddf56de135bfbf0ccb67;p=python 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). --- diff --git a/Modules/timemodule.c b/Modules/timemodule.c index 9ab2724738..4f562c78e9 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; }