VirtualBox

Changeset 9961 in vbox for trunk


Ignore:
Timestamp:
Jun 26, 2008 2:39:54 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
32390
Message:

Extended the testcase.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/testcase/tstGIP-2.cpp

    r9478 r9961  
    4141#include <iprt/thread.h>
    4242#include <iprt/stream.h>
     43#include <iprt/string.h>
    4344#include <iprt/initterm.h>
    4445#include <iprt/getopt.h>
     
    5455    static const RTOPTIONDEF g_aOptions[] =
    5556    {
    56         { "--interations",      'i', RTGETOPT_REQ_INT32 }
     57        { "--interations",      'i', RTGETOPT_REQ_INT32 },
     58        { "--hex",              'h', RTGETOPT_REQ_NOTHING },
     59        { "--decimal",          'd', RTGETOPT_REQ_NOTHING },
     60        { "--spin",             's', RTGETOPT_REQ_NOTHING }
    5761    };
    5862
    5963    uint32_t cIterations = 40;
     64    bool fHex = true;
     65    bool fSpin = false;
    6066    int ch;
    6167    int iArg = 1;
     
    6773            case 'i':
    6874                cIterations = ValueUnion.u32;
     75                break;
     76
     77            case 'd':
     78                fHex = false;
     79                break;
     80
     81            case 'h':
     82                fHex = true;
     83                break;
     84
     85            case 's':
     86                fSpin = true;
    6987                break;
    7088
     
    92110        if (g_pSUPGlobalInfoPage)
    93111        {
    94             RTPrintf("tstGIP-2: u32UpdateHz=%RU32  u32UpdateIntervalNS=%RU32  u64NanoTSLastUpdateHz=%RX64  u32Mode=%d (%s) u32Version=%#x\n"
    95                      "tstGIP-2:     it: u64NanoTS        u64TSC           UpIntTSC H TransId            CpuHz TSC Interval History...\n",
     112            RTPrintf("tstGIP-2: u32UpdateHz=%RU32  u32UpdateIntervalNS=%RU32  u64NanoTSLastUpdateHz=%RX64  u32Mode=%d (%s) u32Version=%#x\n",
    96113                     g_pSUPGlobalInfoPage->u32UpdateHz,
    97114                     g_pSUPGlobalInfoPage->u32UpdateIntervalNS,
     
    102119                     :                                                            "???",
    103120                     g_pSUPGlobalInfoPage->u32Version);
     121            RTPrintf(fHex
     122                     ? "tstGIP-2:     it: u64NanoTS        delta     u64TSC           UpIntTSC H  TransId           CpuHz TSC Interval History...\n"
     123                     : "tstGIP-2:     it: u64NanoTS        delta     u64TSC             UpIntTSC H    TransId           CpuHz TSC Interval History...\n");
     124            static SUPGIPCPU s_aaCPUs[2][RT_ELEMENTS(g_pSUPGlobalInfoPage->aCPUs)];
    104125            for (uint32_t i = 0; i < cIterations; i++)
    105126            {
     127                /* copy the data */
     128                memcpy(&s_aaCPUs[i & 1][0], &g_pSUPGlobalInfoPage->aCPUs[0], sizeof(g_pSUPGlobalInfoPage->aCPUs));
     129
     130                /* display it & find something to spin on. */
     131                uint32_t u32TransactionId = 0;
     132                uint32_t volatile *pu32TransactionId = NULL;
    106133                for (unsigned iCpu = 0; iCpu < RT_ELEMENTS(g_pSUPGlobalInfoPage->aCPUs); iCpu++)
    107134                    if (    g_pSUPGlobalInfoPage->aCPUs[iCpu].u64CpuHz > 0
    108135                        &&  g_pSUPGlobalInfoPage->aCPUs[iCpu].u64CpuHz != _4G + 1)
    109                         RTPrintf("tstGIP-2: %4d/%d: %016llx %016llx %08x %d %08x %15llu %08x %08x %08x %08x %08x %08x %08x %08x (%d)\n",
     136                    {   
     137                        PSUPGIPCPU pPrevCpu = &s_aaCPUs[!(i & 1)][iCpu];
     138                        PSUPGIPCPU pCpu = &s_aaCPUs[i & 1][iCpu];
     139                        RTPrintf(fHex
     140                                 ? "tstGIP-2: %4d/%d: %016llx %09llx %016llx %08x %d %08x %15llu %08x %08x %08x %08x %08x %08x %08x %08x (%d)\n"
     141                                 : "tstGIP-2: %4d/%d: %016llu %09llu %016llu %010u %d %010u %15llu %08x %08x %08x %08x %08x %08x %08x %08x (%d)\n",
    110142                                 i, iCpu,
    111                                  g_pSUPGlobalInfoPage->aCPUs[iCpu].u64NanoTS,
    112                                  g_pSUPGlobalInfoPage->aCPUs[iCpu].u64TSC,
    113                                  g_pSUPGlobalInfoPage->aCPUs[iCpu].u32UpdateIntervalTSC,
    114                                  g_pSUPGlobalInfoPage->aCPUs[iCpu].iTSCHistoryHead,
    115                                  g_pSUPGlobalInfoPage->aCPUs[iCpu].u32TransactionId,
    116                                  g_pSUPGlobalInfoPage->aCPUs[iCpu].u64CpuHz,
    117                                  g_pSUPGlobalInfoPage->aCPUs[iCpu].au32TSCHistory[0],
    118                                  g_pSUPGlobalInfoPage->aCPUs[iCpu].au32TSCHistory[1],
    119                                  g_pSUPGlobalInfoPage->aCPUs[iCpu].au32TSCHistory[2],
    120                                  g_pSUPGlobalInfoPage->aCPUs[iCpu].au32TSCHistory[3],
    121                                  g_pSUPGlobalInfoPage->aCPUs[iCpu].au32TSCHistory[4],
    122                                  g_pSUPGlobalInfoPage->aCPUs[iCpu].au32TSCHistory[5],
    123                                  g_pSUPGlobalInfoPage->aCPUs[iCpu].au32TSCHistory[6],
    124                                  g_pSUPGlobalInfoPage->aCPUs[iCpu].au32TSCHistory[7],
    125                                  g_pSUPGlobalInfoPage->aCPUs[iCpu].cErrors);
    126                 RTThreadSleep(9);
     143                                 pCpu->u64NanoTS,
     144                                 i ? pCpu->u64NanoTS - pPrevCpu->u64NanoTS : 0,
     145                                 pCpu->u64TSC,
     146                                 pCpu->u32UpdateIntervalTSC,
     147                                 pCpu->iTSCHistoryHead,
     148                                 pCpu->u32TransactionId,
     149                                 pCpu->u64CpuHz,
     150                                 pCpu->au32TSCHistory[0],
     151                                 pCpu->au32TSCHistory[1],
     152                                 pCpu->au32TSCHistory[2],
     153                                 pCpu->au32TSCHistory[3],
     154                                 pCpu->au32TSCHistory[4],
     155                                 pCpu->au32TSCHistory[5],
     156                                 pCpu->au32TSCHistory[6],
     157                                 pCpu->au32TSCHistory[7],
     158                                 pCpu->cErrors);
     159                        if (!pu32TransactionId)
     160                        {
     161                            pu32TransactionId = &g_pSUPGlobalInfoPage->aCPUs[iCpu].u32TransactionId;
     162                            u32TransactionId = pCpu->u32TransactionId;
     163                        }
     164                    }
     165
     166                /* wait a bit / spin */
     167                if (!fSpin)
     168                    RTThreadSleep(9);
     169                else
     170                    while (u32TransactionId == *pu32TransactionId)
     171                        /* nop */;
    127172            }
    128173        }
Note: See TracChangeset for help on using the changeset viewer.

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