Changeset 6266 in vbox
- Timestamp:
- Jan 7, 2008 9:58:54 PM (17 years ago)
- Location:
- trunk/src/VBox/Runtime/testcase
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/Makefile.kmk
r5999 r6266 58 58 tstTime-2 \ 59 59 tstTime-3 \ 60 tstTime-4 \ 60 61 tstTimer \ 61 62 tstTimeSpec \ … … 88 89 TEMPLATE = VBOXR3TSTEXE 89 90 91 tstTime_SOURCES = tstTime.cpp 92 93 tstTime-2_SOURCES = tstTime-2.cpp 94 95 tstTime-3_SOURCES = tstTime-3.cpp 96 97 tstTime-4_SOURCES = tstTime-4.cpp 98 99 tstTimeSpec_SOURCES = tstTimeSpec.cpp 90 100 91 101 tstTimer_SOURCES = tstTimer.cpp … … 93 103 tstTSC_SOURCES = tstTSC.cpp 94 104 tstTSC_CXXFLAGS.linux += -O3 95 96 tstTime_SOURCES = tstTime.cpp97 98 tstTime-2_SOURCES = tstTime-2.cpp99 100 tstTime-3_SOURCES = tstTime-3.cpp101 102 tstTimeSpec_SOURCES = tstTimeSpec.cpp103 105 104 106 tstStrFormat_SOURCES = tstStrFormat.cpp -
trunk/src/VBox/Runtime/testcase/tstTime-4.cpp
r6257 r6266 1 1 /* $Id$ */ 2 2 /** @file 3 * innotek Portable Runtime Testcase - Simple RTTime test.3 * innotek Portable Runtime Testcase - Simple RTTime vs. RTTimeSystem test. 4 4 */ 5 5 … … 30 30 #include <iprt/time.h> 31 31 #include <iprt/stream.h> 32 #include <iprt/ runtime.h>32 #include <iprt/initterm.h> 33 33 #include <iprt/thread.h> 34 34 #include <VBox/sup.h> … … 39 39 { 40 40 unsigned cErrors = 0; 41 int i; 41 42 42 RTR3Init(); 43 RTPrintf("tstTime- 2: TESTING...\n");43 RTPrintf("tstTime-4: TESTING...\n"); 44 44 45 45 /* 46 * RTNanoTimeTS() shall never return something which47 * is less or equal to the return of the previous call.46 * Check that RTTimeSystemNanoTS doesn't go backwards and 47 * isn't too far from RTTimeNanoTS(). 48 48 */ 49 RTTimeSystemNanoTS(); RTTimeNanoTS(); RTThreadYield(); /* warmup */ 50 const uint64_t SysStartTS = RTTimeSystemNanoTS(); 51 const uint64_t GipStartTS = RTTimeNanoTS(); 52 uint64_t SysPrevTS, GipPrevTS; 53 do 54 { 55 SysPrevTS = RTTimeSystemNanoTS(); 56 GipPrevTS = RTTimeNanoTS(); 57 if (SysPrevTS < SysStartTS) 58 { 59 cErrors++; 60 RTPrintf("tstTime-4: Bad Sys time!\n"); 61 } 62 if (GipPrevTS < GipStartTS) 63 { 64 cErrors++; 65 RTPrintf("tstTime-4: Bad Gip time!\n"); 66 } 67 int64_t Delta = GipPrevTS - SysPrevTS; 68 if (Delta > 0 ? Delta > 100000000 /* 100 ms */ : Delta < -100000000 /* -100 ms */) 69 { 70 cErrors++; 71 RTPrintf("tstTime-4: Delta=%lld!\n", Delta); 72 } 49 73 50 RTTimeSystemNanoTS(); RTTimeNanoTS(); RTThreadYield(); 51 uint64_t u64RTStartTS = RTTimeNanoTS(); 52 uint64_t u64OSStartTS = RTTimeSystemNanoTS(); 53 #define NUMBER_OF_CALLS (100*_1M) 74 } while (SysPrevTS - SysStartTS < 2000000000 /* 2s */); 54 75 55 for (i = 0; i < NUMBER_OF_CALLS; i++)56 RTTimeNanoTS();57 58 uint64_t u64RTElapsedTS = RTTimeNanoTS();59 uint64_t u64OSElapsedTS = RTTimeSystemNanoTS();60 u64RTElapsedTS -= u64RTStartTS;61 u64OSElapsedTS -= u64OSStartTS;62 int64_t i64Diff = u64OSElapsedTS >= u64RTElapsedTS ? u64OSElapsedTS - u64RTElapsedTS : u64RTElapsedTS - u64OSElapsedTS;63 if (i64Diff > (int64_t)(u64OSElapsedTS / 1000))64 {65 RTPrintf("tstTime-2: error: total time differs too much! u64OSElapsedTS=%#llx u64RTElapsedTS=%#llx delta=%lld\n",66 u64OSElapsedTS, u64RTElapsedTS, u64OSElapsedTS - u64RTElapsedTS);67 cErrors++;68 }69 else70 RTPrintf("tstTime-2: total time difference: u64OSElapsedTS=%#llx u64RTElapsedTS=%#llx delta=%lld\n",71 u64OSElapsedTS, u64RTElapsedTS, u64OSElapsedTS - u64RTElapsedTS);72 73 RTPrintf("tstTime-2: %u calls to RTTimeNanoTS\n", NUMBER_OF_CALLS);74 RTPrintf("tstTime-2: RTTimeDbgSteps -> %u (%d ppt)\n", RTTimeDbgSteps(), ((uint64_t)RTTimeDbgSteps() * 1000) / NUMBER_OF_CALLS);75 RTPrintf("tstTime-2: RTTimeDbgExpired -> %u (%d ppt)\n", RTTimeDbgExpired(), ((uint64_t)RTTimeDbgExpired() * 1000) / NUMBER_OF_CALLS);76 RTPrintf("tstTime-2: RTTimeDbgBad -> %u (%d ppt)\n", RTTimeDbgBad(), ((uint64_t)RTTimeDbgBad() * 1000) / NUMBER_OF_CALLS);77 RTPrintf("tstTime-2: RTTimeDbgRaces -> %u (%d ppt)\n", RTTimeDbgRaces(), ((uint64_t)RTTimeDbgRaces() * 1000) / NUMBER_OF_CALLS);78 76 79 77 if (!cErrors) 80 RTPrintf("tstTime- 2: SUCCESS\n");78 RTPrintf("tstTime-4: SUCCESS\n"); 81 79 else 82 RTPrintf("tstTime- 2: FAILURE - %d errors\n", cErrors);80 RTPrintf("tstTime-4: FAILURE - %d errors\n", cErrors); 83 81 return !!cErrors; 84 82 } 83
Note:
See TracChangeset
for help on using the changeset viewer.