Changeset 41781 in vbox for trunk/src/VBox/Disassembler/testcase/tstDisasm-1.cpp
- Timestamp:
- Jun 16, 2012 7:02:30 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 78599
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Disassembler/testcase/tstDisasm-1.cpp
r41751 r41781 24 24 #include <iprt/string.h> 25 25 #include <iprt/err.h> 26 #include <iprt/time.h> 26 27 27 28 … … 73 74 off += cb; 74 75 } 76 } 75 77 78 static void testPerformance(const char *pszSub, uint8_t const *pabInstrs, uintptr_t uEndPtr, DISCPUMODE enmDisCpuMode) 79 { 80 RTTestISubF("Performance - %s", pszSub); 81 82 size_t const cbInstrs = uEndPtr - (uintptr_t)pabInstrs; 83 uint64_t cInstrs = 0; 84 uint64_t nsStart = RTTimeNanoTS(); 85 for (uint32_t i = 0; i < _512K; i++) /* the samples are way to small. :-) */ 86 { 87 for (size_t off = 0; off < cbInstrs; cInstrs++) 88 { 89 uint32_t cb = 1; 90 DISCPUSTATE Cpu; 91 DISInstr(&pabInstrs[off], enmDisCpuMode, &Cpu, &cb); 92 off += cb; 93 } 94 } 95 uint64_t cNsElapsed = RTTimeNanoTS() - nsStart; 96 97 RTTestIValueF(cNsElapsed, RTTESTUNIT_NS, "%s-Total", pszSub); 98 RTTestIValueF(cNsElapsed / cInstrs, RTTESTUNIT_NS_PER_CALL, "%s-per-instruction", pszSub); 76 99 } 77 100 … … 85 108 RTTestBanner(hTest); 86 109 87 testDisas("32-bit", (uint8_t const *)(uintptr_t)TestProc32, (uintptr_t)&TestProc32_EndProc, DISCPUMODE_32BIT); 88 #ifndef RT_OS_OS2 89 testDisas("64-bit", (uint8_t const *)(uintptr_t)TestProc64, (uintptr_t)&TestProc64_EndProc, DISCPUMODE_64BIT); 90 #endif 110 static const struct 111 { 112 const char *pszDesc; 113 uint8_t const *pbStart; 114 uintptr_t uEndPtr; 115 DISCPUMODE enmCpuMode; 116 } aSnippets[] = 117 { 118 { "32-bit", (uint8_t const *)(uintptr_t)TestProc32, (uintptr_t)&TestProc32_EndProc, DISCPUMODE_32BIT }, 119 { "64-bit", (uint8_t const *)(uintptr_t)TestProc64, (uintptr_t)&TestProc64_EndProc, DISCPUMODE_64BIT }, 120 }; 121 122 for (unsigned i = 0; i < RT_ELEMENTS(aSnippets); i++) 123 testDisas(aSnippets[i].pszDesc, aSnippets[i].pbStart, aSnippets[i].uEndPtr, aSnippets[i].enmCpuMode); 124 125 if (RTTestIErrorCount() == 0) 126 { 127 for (unsigned i = 0; i < RT_ELEMENTS(aSnippets); i++) 128 testPerformance(aSnippets[i].pszDesc, aSnippets[i].pbStart, aSnippets[i].uEndPtr, aSnippets[i].enmCpuMode); 129 } 91 130 92 131 return RTTestSummaryAndDestroy(hTest);
Note:
See TracChangeset
for help on using the changeset viewer.