aboutsummaryrefslogtreecommitdiffstats
path: root/mps/code
diff options
context:
space:
mode:
authorNick Barnes2002-07-04 16:41:03 +0100
committerNick Barnes2002-07-04 16:41:03 +0100
commit175b300c786312ee7310fb88e2f93c8cd7e00d28 (patch)
treecb54319e3f94019f1e0f20912633891916fc9364 /mps/code
parent44cb42a24859c9304f2d18816f0ca397d9a05475 (diff)
downloademacs-175b300c786312ee7310fb88e2f93c8cd7e00d28.tar.gz
emacs-175b300c786312ee7310fb88e2f93c8cd7e00d28.zip
Improve clock calibration so it does a better job on low-granularity clocks.
Copied from Perforce Change: 30792 ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
-rw-r--r--mps/code/steptest.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/mps/code/steptest.c b/mps/code/steptest.c
index b4bcc037aa2..eca90727625 100644
--- a/mps/code/steptest.c
+++ b/mps/code/steptest.c
@@ -149,7 +149,8 @@ static double my_clock(void)
149 149
150double clock_time; /* current estimate of time to read the clock */ 150double clock_time; /* current estimate of time to read the clock */
151 151
152#define CLOCK_TESTS 20000 152/* take at least this many microseconds to set the clock */
153#define CLOCK_TIME_SET 10000
153 154
154/* set_clock_timing() sets clock_time. */ 155/* set_clock_timing() sets clock_time. */
155 156
@@ -160,12 +161,14 @@ static void set_clock_timing(void)
160 161
161 t2 = 0.0; 162 t2 = 0.0;
162 t3 = my_clock(); 163 t3 = my_clock();
163 for (i=0; i<CLOCK_TESTS; ++i) { 164 i = 0;
165 do {
164 t1 = my_clock(); 166 t1 = my_clock();
165 /* do nothing here */ 167 /* do nothing here */
166 t2 += my_clock()-t1; 168 t2 += my_clock()-t1;
167 } 169 ++i;
168 clock_time = t2/CLOCK_TESTS; 170 } while (t1 < t3 + CLOCK_TIME_SET);
171 clock_time = t2/i;
169 total_clock_time += my_clock() - t3 + clock_time; 172 total_clock_time += my_clock() - t3 + clock_time;
170} 173}
171 174