VirtualBox

Changeset 74534 in vbox for trunk/src/VBox/VMM/testcase


Ignore:
Timestamp:
Sep 30, 2018 3:17:04 PM (6 years ago)
Author:
vboxsync
Message:

VMM/testcase: Made NemRawBench-1 build again on windows and reran it. bugref:9044

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/testcase/NemRawBench-1.cpp

    r74533 r74534  
    2323# include <iprt/win/windows.h>
    2424# include <WinHvPlatform.h>
    25 typedef unsigned long long uint64_t;
     25# if !defined(_INTPTR) && defined(_M_AMD64) /* void pedantic stdint.h warnings  */
     26#  define _INTPTR 2
     27# endif
    2628
    2729#elif defined(RT_OS_LINUX)
     
    173175    char szTmp[64 + 22];
    174176#ifdef _MSC_VER
    175     size_t cchTmp = snprintf(szTmp, sizeof(szTmp) - 22, "%I64u", uNum);
     177    size_t cchTmp = _snprintf(szTmp, sizeof(szTmp) - 22, "%I64u", uNum);
    176178#else
    177179    size_t cchTmp = snprintf(szTmp, sizeof(szTmp) - 22, "%llu", uNum);
    178180#endif
    179181    size_t cSeps  = (cchTmp - 1) / 3;
     182    size_t const cchTotal = cchTmp + cSeps;
    180183    if (cSeps)
    181184    {
    182         szTmp[cchTmp + cSeps] = '\0';
    183         for (size_t iSrc = cchTmp, iDst = cchTmp + cSeps; cSeps > 0; cSeps--)
     185        szTmp[cchTotal] = '\0';
     186        for (size_t iSrc = cchTmp, iDst = cchTotal; cSeps > 0; cSeps--)
    184187        {
    185188            szTmp[--iDst] = szTmp[--iSrc];
     
    189192        }
    190193    }
    191     snprintf(pszDst, cbDst, "%*s", cchWidth, szTmp);
     194
     195    size_t offDst = 0;
     196    while (cchWidth-- > cchTotal && offDst < cbDst)
     197        pszDst[offDst++] = ' ';
     198    size_t offSrc = 0;
     199    while (offSrc < cchTotal && offDst < cbDst)
     200        pszDst[offDst++] = szTmp[offSrc++];
     201    pszDst[offDst] = '\0';
    192202    return pszDst;
    193203}
     204
     205
     206int reportResult(const char *pszInstruction, uint32_t cInstructions, uint64_t nsElapsed, uint32_t cExits)
     207{
     208    uint64_t const cInstrPerSec = nsElapsed ? (uint64_t)cInstructions * 1000000000 / nsElapsed : 0;
     209    char szTmp1[64], szTmp2[64], szTmp3[64];
     210    printf("%s %7s instructions per second (%s exits in %s ns)\n",
     211           formatNum(cInstrPerSec, 10, szTmp1, sizeof(szTmp1)), pszInstruction,
     212           formatNum(cExits, 0, szTmp2, sizeof(szTmp2)),
     213           formatNum(nsElapsed, 0, szTmp3, sizeof(szTmp3)));
     214    return 0;
     215}
     216
    194217
    195218
     
    405428     * Run the test.
    406429     */
     430    uint32_t cExits = 0;
    407431    uint64_t const nsStart = getNanoTS();
    408432    for (;;)
     
    413437        if (SUCCEEDED(hrc))
    414438        {
     439            cExits++;
    415440            if (ExitInfo.ExitReason == WHvRunVpExitReasonX64IoPortAccess)
    416441            {
     
    488513    }
    489514    uint64_t const nsElapsed = getNanoTS() - nsStart;
    490 
    491     /* Report the results. */
    492     uint64_t const cInstrPerSec = nsElapsed ? (uint64_t)cInstructions * 1000000000 / nsElapsed : 0;
    493     printf("%10u %s instructions per second\n", (unsigned)cInstrPerSec, pszInstruction);
    494     return 0;
     515    return reportResult(pszInstruction, cInstructions, nsElapsed, cExits);
    495516}
    496517
     
    668689     * Run the test.
    669690     */
     691    uint32_t cExits = 0;
    670692    uint64_t const nsStart = getNanoTS();
    671693    for (;;)
     
    674696        if (rc == 0)
    675697        {
     698            cExits++;
    676699            if (g_pVCpuRun->exit_reason == KVM_EXIT_IO)
    677700            {
     
    697720    }
    698721    uint64_t const nsElapsed = getNanoTS() - nsStart;
    699 
    700     /* Report the results. */
    701     uint64_t const cInstrPerSec = nsElapsed ? (uint64_t)cInstructions * 1000000000 / nsElapsed : 0;
    702     printf("%10u %s instructions per second\n", (unsigned)cInstrPerSec, pszInstruction);
    703     return 0;
     722    return reportResult(pszInstruction, cInstructions, nsElapsed, cExits);
    704723}
    705724
     
    978997    uint32_t cExits = 0;
    979998    uint64_t const nsStart = getNanoTS();
    980     for (;; cExits++)
     999    for (;;)
    9811000    {
    9821001        hv_return_t rcHv = hv_vcpu_run(g_idVCpu);
    9831002        if (rcHv == HV_SUCCESS)
    9841003        {
     1004            cExits++;
    9851005            uint64_t uExitReason = UINT64_MAX;
    9861006            READ_VMCS_RET(VMCS_RO_EXIT_REASON, &uExitReason);
     
    10591079    }
    10601080    uint64_t const nsElapsed = getNanoTS() - nsStart;
    1061 
    1062     /* Report the results. */
    1063     char szTmp1[64], szTmp2[64], szTmp3[64];
    1064     uint64_t const cInstrPerSec = nsElapsed ? (uint64_t)cInstructions * 1000000000 / nsElapsed : 0;
    1065     printf("%s %7s instructions per second (%s exits in %s ns)\n",
    1066            formatNum(cInstrPerSec, 10, szTmp1, sizeof(szTmp1)), pszInstruction,
    1067            formatNum(cExits, 0, szTmp2, sizeof(szTmp2)),
    1068            formatNum(nsElapsed, 0, szTmp3, sizeof(szTmp3)));
    1069     return 0;
     1081    return reportResult(pszInstruction, cInstructions, nsElapsed, cExits);
    10701082}
    10711083
     
    12661278 * Results:
    12671279 *
    1268  * - Linux 4.18.0-1-amd64 (debian); AMD Threadripper:
    1269  *     545108 OUT instructions per second
    1270  *     373159 MMIO/r1 instructions per second
    1271  *
    1272  * - Windows 1803 updated as per 2018-09-28; AMD Threadripper:
    1273  *      45433 OUT instructions per second
    1274  *      39767 CPUID instructions per second
    1275  *      39088 MMIO/r1 instructions per second
    1276  *
    1277  * - Darwin/xnu 10.12.6/16.7.0; 3.1GHz Core i7-7920HQ (Kaby Lake):
     1280 * - Darwin/xnu 10.12.6/16.7.0; 3.1GHz Intel Core i7-7920HQ (Kaby Lake):
    12781281 *    925 845     OUT instructions per second (3 200 307 exits in 3 456 301 621 ns)
    12791282 *    949 278   CPUID instructions per second (3 200 222 exits in 3 370 980 173 ns)
    12801283 *    871 499 MMIO/r1 instructions per second (3 200 223 exits in 3 671 834 221 ns)
     1284 *
     1285 * - Linux 4.18.0-1-amd64 (debian); 3.4GHz AMD Threadripper 1950X:
     1286 *     545108[incorrect] OUT instructions per second
     1287 *     373159[incorrect] MMIO/r1 instructions per second
     1288 *
     1289 * - Windows 1803 updated as per 2018-09-28; 3.4GHz AMD Threadripper 1950X:
     1290 *     34 485     OUT instructions per second (400 001 exits in 11 598 918 200 ns)
     1291 *     34 043   CPUID instructions per second (400 001 exits in 11 749 753 200 ns)
     1292 *     33 124 MMIO/r1 instructions per second (400 001 exits in 12 075 617 000 ns)
    12811293 */
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