[pypy-svn] r41635 - in pypy/dist/pypy: module/rctime translator/c/src

antocuni at codespeak.net antocuni at codespeak.net
Thu Mar 29 17:27:09 CEST 2007


Author: antocuni
Date: Thu Mar 29 17:27:06 2007
New Revision: 41635

Modified:
   pypy/dist/pypy/module/rctime/interp_time.py
   pypy/dist/pypy/translator/c/src/ll_time.h
Log:
(birkenfeld, a lot of people around)

Make the windows version of rctime.clock() behaving as CPython.



Modified: pypy/dist/pypy/module/rctime/interp_time.py
==============================================================================
--- pypy/dist/pypy/module/rctime/interp_time.py	(original)
+++ pypy/dist/pypy/module/rctime/interp_time.py	Thu Mar 29 17:27:06 2007
@@ -83,6 +83,9 @@
     QueryPerformanceCounter = windll.kernel32.QueryPerformanceCounter
     QueryPerformanceCounter.argtypes = [POINTER(LARGE_INTEGER)]
     QueryPerformanceCounter.restype = BOOL
+    QueryPerformanceFrequency = windll.kernel32.QueryPerformanceFrequency
+    QueryPerformanceFrequency.argtypes = [POINTER(LARGE_INTEGER)]
+    QueryPerformanceFrequency.restype = BOOL
     Sleep = windll.kernel32.Sleep
     Sleep.argtypes = [DWORD]
     Sleep.restype = None
@@ -312,9 +315,9 @@
     elif _WIN:
         if pccache.divisor == 0.0:
             freq = LARGE_INTEGER()
-            res = QueryPerformanceCounter(byref(freq))
+            res = QueryPerformanceFrequency(byref(freq))
             if not res or not freq:
-                return space.wrap(float(libc.clock()))
+                return space.wrap(float(libc.clock()) / CLOCKS_PER_SEC)
             pccache.divisor = float(freq.value)
             QueryPerformanceCounter(byref(pccache.ctrStart))
 

Modified: pypy/dist/pypy/translator/c/src/ll_time.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/ll_time.h	(original)
+++ pypy/dist/pypy/translator/c/src/ll_time.h	Thu Mar 29 17:27:06 2007
@@ -39,7 +39,7 @@
 		if (!QueryPerformanceFrequency(&freq) || freq.QuadPart == 0) {
 			/* Unlikely to happen - this works on all intel
 			   machines at least!  Revert to clock() */
-			return clock();
+			return ((double)clock()) / CLOCKS_PER_SEC;
 		}
 		divisor = (double)freq.QuadPart;
 	}



More information about the Pypy-commit mailing list