[pypy-svn] pypy jit-lsprofile: Improve the performance on win32. Untested.

arigo commits-noreply at bitbucket.org
Wed Jan 5 18:26:27 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: jit-lsprofile
Changeset: r40411:3e7984fd6480
Date: 2011-01-05 18:26 +0100
http://bitbucket.org/pypy/pypy/changeset/3e7984fd6480/

Log:	Improve the performance on win32. Untested.

diff --git a/pypy/translator/c/src/timer.h b/pypy/translator/c/src/timer.h
--- a/pypy/translator/c/src/timer.h
+++ b/pypy/translator/c/src/timer.h
@@ -12,11 +12,15 @@
 
 #  ifdef _WIN32
     double pypy_read_timestamp_double(void) {
+        static double pypy_timer_scale = 0.0;
         long long timestamp;
         long long scale;
         QueryPerformanceCounter((LARGE_INTEGER*)&(timestamp));
-        QueryPerformanceFrequency((LARGE_INTEGER*)&(scale));
-        return ((double)timestamp) / scale;
+        if (pypy_timer_scale == 0.0) {
+          QueryPerformanceFrequency((LARGE_INTEGER*)&(scale));
+          pypy_timer_scale = 1.0 / (double)scale;
+        }
+        return ((double)timestamp) * pypy_timer_scale;
     }
 
 #  else


More information about the Pypy-commit mailing list