VirtualBox

Ignore:
Timestamp:
Jun 16, 2012 7:02:30 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
78599
Message:

DIS: Prefetch instruction bytes before starting to disassemble, inline all fetchers. Poison the state a bit in strict builds.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Disassembler/testcase/tstDisasm-1.cpp

    r41751 r41781  
    2424#include <iprt/string.h>
    2525#include <iprt/err.h>
     26#include <iprt/time.h>
    2627
    2728
     
    7374        off += cb;
    7475    }
     76}
    7577
     78static 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);
    7699}
    77100
     
    85108    RTTestBanner(hTest);
    86109
    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    }
    91130
    92131    return RTTestSummaryAndDestroy(hTest);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette