Changeset 60191 in vbox for trunk/src/VBox/Runtime/testcase
- Timestamp:
- Mar 25, 2016 4:59:31 PM (9 years ago)
- Location:
- trunk/src/VBox/Runtime/testcase
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/Makefile.kmk
r59675 r60191 543 543 tstPrfRT_TEMPLATE = VBOXR3TSTEXE 544 544 tstPrfRT_SOURCES = tstPrfRT.cpp 545 tstPrfRT_SOURCES.x86 = tstRTPrfA.asm 546 tstPrfRT_SOURCES.amd64 = tstRTPrfA.asm 545 547 546 548 tstRTPrfIO_TEMPLATE = VBOXR3TSTEXE -
trunk/src/VBox/Runtime/testcase/tstPrfRT.cpp
r57358 r60191 32 32 #include <iprt/time.h> 33 33 #include <iprt/log.h> 34 #include <iprt/ stream.h>34 #include <iprt/test.h> 35 35 #include <iprt/thread.h> 36 36 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) 37 37 # include <iprt/asm-amd64-x86.h> 38 38 #endif 39 40 41 /********************************************************************************************************************************* 42 * Internal Functions * 43 *********************************************************************************************************************************/ 44 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) 45 DECLASM(void) tstRTPRfAMemoryAccess(void); 46 DECLASM(void) tstRTPRfARegisterAccess(void); 47 DECLASM(void) tstRTPRfAMemoryUnalignedAccess(void); 48 #endif 49 50 51 /********************************************************************************************************************************* 52 * Global Variables * 53 *********************************************************************************************************************************/ 54 static RTTEST g_hTest; 55 56 57 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) 39 58 40 59 void PrintResult(uint64_t u64Ticks, uint64_t u64MaxTicks, uint64_t u64MinTicks, unsigned cTimes, const char *pszOperation) 41 60 { 42 RTPrintf("tstPrfRT: %-32s %5lld / %5lld / %5lld ticks per call (%u calls %lld ticks)\n", 43 pszOperation, u64MinTicks, u64Ticks / (uint64_t)cTimes, u64MaxTicks, cTimes, u64Ticks); 61 //RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, 62 // "%-32s %5lld / %5lld / %5lld ticks per call (%u calls %lld ticks)\n", 63 // pszOperation, u64MinTicks, u64Ticks / (uint64_t)cTimes, u64MaxTicks, cTimes, u64Ticks); 64 //RTTestValueF(g_hTest, u64MinTicks, RTTESTUNIT_NONE, "%s min ticks", pszOperation); 65 RTTestValueF(g_hTest, u64Ticks / (uint64_t)cTimes, RTTESTUNIT_NONE, "%s avg ticks", pszOperation); 66 //RTTestValueF(g_hTest, u64MaxTicks, RTTESTUNIT_NONE, "%s max ticks", pszOperation); 44 67 } 45 68 … … 91 114 void PrintResult(uint64_t cNs, uint64_t cNsMax, uint64_t cNsMin, unsigned cTimes, const char *pszOperation) 92 115 { 93 RTPrintf("tstPrfRT: %-32s %5lld / %5lld / %5lld ns per call (%u calls %lld ns)\n", 94 pszOperation, cNsMin, cNs / (uint64_t)cTimes, cNsMax, cTimes, cNs); 116 //RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, 117 // "%-32s %5lld / %5lld / %5lld ns per call (%u calls %lld ns)\n", 118 // pszOperation, cNsMin, cNs / (uint64_t)cTimes, cNsMax, cTimes, cNs); 119 //RTTestValueF(g_hTest, cNsMin, RTTESTUNIT_NS_PER_CALL, "%s min", pszOperation); 120 RTTestValueF(g_hTest, cNs / (uint64_t)cTimes, RTTESTUNIT_NS_PER_CALL, "%s avg", pszOperation); 121 //RTTestValueF(g_hTest, cNsMax, RTTESTUNIT_NS_PER_CALL, "%s max", pszOperation); 95 122 } 96 123 … … 125 152 unsigned i; 126 153 127 RTR3InitExeNoArguments(argc == 2 ? RTR3INIT_FLAGS_SUPLIB : 0); 128 RTPrintf("tstPrfRT: TESTING...\n"); 154 RTEXITCODE rcExit = RTTestInitExAndCreate(argc, &argv, argc == 2 ? RTR3INIT_FLAGS_SUPLIB : 0, "tstRTPrf", &g_hTest); 155 if (rcExit != RTEXITCODE_SUCCESS) 156 return rcExit; 157 RTTestBanner(g_hTest); 129 158 130 159 /* … … 165 194 PrintResult(u64TotalTS, u64MaxTS, u64MinTS, i, "RTThreadNativeSelf"); 166 195 167 RTPrintf("tstPrtRT: DONE\n"); 168 return 0; 196 #if defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64) 197 /* 198 * Registers vs stack. 199 */ 200 ITERATE(RT_NOTHING, tstRTPRfARegisterAccess();, RT_NOTHING, 1000); 201 uint64_t const cRegTotal = u64TotalTS; 202 //PrintResult(u64TotalTS, u64MaxTS, u64MinTS, i, "Register only algorithm"); 203 204 ITERATE(RT_NOTHING, tstRTPRfAMemoryAccess();, RT_NOTHING, 1000); 205 uint64_t const cMemTotal = u64TotalTS; 206 //PrintResult(u64TotalTS, u64MaxTS, u64MinTS, i, "Memory only algorithm"); 207 208 ITERATE(RT_NOTHING, tstRTPRfAMemoryUnalignedAccess();, RT_NOTHING, 1000); 209 uint64_t const cMemUnalignedTotal = u64TotalTS; 210 //PrintResult(u64TotalTS, u64MaxTS, u64MinTS, i, "Memory only algorithm"); 211 212 uint64_t const cSlower100 = cMemTotal * 100 / cRegTotal; 213 RTTestValue(g_hTest, "Memory instead of registers slowdown", cSlower100, RTTESTUNIT_PCT); 214 uint64_t const cUnalignedSlower100 = cMemUnalignedTotal * 100 / cRegTotal; 215 RTTestValue(g_hTest, "Unaligned memory instead of registers slowdown", cUnalignedSlower100, RTTESTUNIT_PCT); 216 #endif 217 218 return RTTestSummaryAndDestroy(g_hTest); 169 219 }
Note:
See TracChangeset
for help on using the changeset viewer.