]> granicus.if.org Git - python/commitdiff
In Windows' time.clock(), when QueryPerformanceFrequency() fails,
authorGeorg Brandl <georg@python.org>
Thu, 29 Mar 2007 12:42:16 +0000 (12:42 +0000)
committerGeorg Brandl <georg@python.org>
Thu, 29 Mar 2007 12:42:16 +0000 (12:42 +0000)
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)

Modules/timemodule.c

index 444b739fe72355168acaeb0657fa9ce010042695..283ab5fd7b7b1fb45b6ea7abb4d0b9adc4f5da84 100644 (file)
@@ -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;
        }