Changeset 1537 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Mar 16, 2007 5:02:13 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstTimer.cpp
r1 r1537 36 36 *******************************************************************************/ 37 37 static volatile unsigned gcTicks; 38 static volatile uint64_t gu64Min; 39 static volatile uint64_t gu64Max; 40 static volatile uint64_t gu64Prev; 38 41 39 42 static DECLCALLBACK(void) TimerCallback(PRTTIMER pTimer, void *pvUser) 40 43 { 41 44 gcTicks++; 45 46 const uint64_t u64Now = RTTimeNanoTS(); 47 if (gu64Prev) 48 { 49 const uint64_t u64Delta = u64Now - gu64Prev; 50 if (u64Delta < gu64Min) 51 gu64Min = u64Delta; 52 if (u64Delta > gu64Max) 53 gu64Max = u64Delta; 54 } 55 gu64Prev = u64Now; 42 56 } 43 57 … … 125 139 gcTicks = 0; 126 140 PRTTIMER pTimer; 141 gu64Max = 0; 142 gu64Min = UINT64_MAX; 143 gu64Prev = 0; 127 144 rc = RTTimerCreate(&pTimer, aTests[i].uMilliesInterval, TimerCallback, NULL); 128 145 if (RT_FAILURE(rc)) … … 134 151 135 152 /* 136 * Sleep for a while and then killit.153 * Active waiting for 2 seconds and then destroy it. 137 154 */ 138 155 uint64_t uTSBegin = RTTimeNanoTS(); 139 #if 1140 156 while (RTTimeNanoTS() - uTSBegin < (uint64_t)aTests[i].uMilliesWait * 1000000) 141 157 /* nothing */; 142 143 #else144 rc = RTThreadSleep(aTests[i].uMilliesWait);145 #endif146 158 uint64_t uTSEnd = RTTimeNanoTS(); 147 159 uint64_t uTSDiff = uTSEnd - uTSBegin; … … 170 182 if (gcTicks < aTests[i].cLower) 171 183 { 172 RTPrintf("tstTimer: FAILURE - Too few ticks gcTicks=%d (expected %d-%d) \n", gcTicks, aTests[i].cUpper, aTests[i].cLower);184 RTPrintf("tstTimer: FAILURE - Too few ticks gcTicks=%d (expected %d-%d)", gcTicks, aTests[i].cUpper, aTests[i].cLower); 173 185 cErrors++; 174 186 } 175 187 else if (gcTicks > aTests[i].cUpper) 176 188 { 177 RTPrintf("tstTimer: FAILURE - Too many ticks gcTicks=%d (expected %d-%d) \n", gcTicks, aTests[i].cUpper, aTests[i].cLower);189 RTPrintf("tstTimer: FAILURE - Too many ticks gcTicks=%d (expected %d-%d)", gcTicks, aTests[i].cUpper, aTests[i].cLower); 178 190 cErrors++; 179 191 } 180 192 else 181 RTPrintf("tstTimer: OK - gcTicks=%d\n", gcTicks); 193 RTPrintf("tstTimer: OK - gcTicks=%d", gcTicks); 194 RTPrintf(" min=%RU64 max=%RU64\n", gu64Min, gu64Max); 182 195 } 183 196
Note:
See TracChangeset
for help on using the changeset viewer.