Changeset 74534 in vbox
- Timestamp:
- Sep 30, 2018 3:17:04 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/testcase/NemRawBench-1.cpp
r74533 r74534 23 23 # include <iprt/win/windows.h> 24 24 # 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 26 28 27 29 #elif defined(RT_OS_LINUX) … … 173 175 char szTmp[64 + 22]; 174 176 #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); 176 178 #else 177 179 size_t cchTmp = snprintf(szTmp, sizeof(szTmp) - 22, "%llu", uNum); 178 180 #endif 179 181 size_t cSeps = (cchTmp - 1) / 3; 182 size_t const cchTotal = cchTmp + cSeps; 180 183 if (cSeps) 181 184 { 182 szTmp[cchT mp + cSeps] = '\0';183 for (size_t iSrc = cchTmp, iDst = cchT mp + cSeps; cSeps > 0; cSeps--)185 szTmp[cchTotal] = '\0'; 186 for (size_t iSrc = cchTmp, iDst = cchTotal; cSeps > 0; cSeps--) 184 187 { 185 188 szTmp[--iDst] = szTmp[--iSrc]; … … 189 192 } 190 193 } 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'; 192 202 return pszDst; 193 203 } 204 205 206 int 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 194 217 195 218 … … 405 428 * Run the test. 406 429 */ 430 uint32_t cExits = 0; 407 431 uint64_t const nsStart = getNanoTS(); 408 432 for (;;) … … 413 437 if (SUCCEEDED(hrc)) 414 438 { 439 cExits++; 415 440 if (ExitInfo.ExitReason == WHvRunVpExitReasonX64IoPortAccess) 416 441 { … … 488 513 } 489 514 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); 495 516 } 496 517 … … 668 689 * Run the test. 669 690 */ 691 uint32_t cExits = 0; 670 692 uint64_t const nsStart = getNanoTS(); 671 693 for (;;) … … 674 696 if (rc == 0) 675 697 { 698 cExits++; 676 699 if (g_pVCpuRun->exit_reason == KVM_EXIT_IO) 677 700 { … … 697 720 } 698 721 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); 704 723 } 705 724 … … 978 997 uint32_t cExits = 0; 979 998 uint64_t const nsStart = getNanoTS(); 980 for (;; cExits++)999 for (;;) 981 1000 { 982 1001 hv_return_t rcHv = hv_vcpu_run(g_idVCpu); 983 1002 if (rcHv == HV_SUCCESS) 984 1003 { 1004 cExits++; 985 1005 uint64_t uExitReason = UINT64_MAX; 986 1006 READ_VMCS_RET(VMCS_RO_EXIT_REASON, &uExitReason); … … 1059 1079 } 1060 1080 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); 1070 1082 } 1071 1083 … … 1266 1278 * Results: 1267 1279 * 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): 1278 1281 * 925 845 OUT instructions per second (3 200 307 exits in 3 456 301 621 ns) 1279 1282 * 949 278 CPUID instructions per second (3 200 222 exits in 3 370 980 173 ns) 1280 1283 * 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) 1281 1293 */
Note:
See TracChangeset
for help on using the changeset viewer.