Changeset 6777 in vbox for trunk/src/VBox/Runtime/testcase
- Timestamp:
- Feb 4, 2008 8:49:41 AM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 27868
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstInlineAsm.cpp
r6644 r6777 921 921 } 922 922 923 /* 924 * Make this static. We don't want to have this located on the stack. 925 */ 926 static volatile uint32_t g_u32; 927 928 #define BENCH(ins, str) \ 929 RTThreadYield(); \ 930 u64Start = ASMReadTSC(); \ 931 for (i = cRounds; i > 0; i--) \ 932 ins; \ 933 u64Stop = ASMReadTSC(); \ 934 RTPrintf(" %-10s %3llu cycles\n", str, (u64Stop - u64Start) / cRounds); 935 936 void tstASMBench() 937 { 938 register unsigned i; 939 const unsigned cRounds = 1000000; 940 register uint64_t u64Start, u64Stop; 941 942 RTPrintf("Benchmarking some low-level instructions:\n"); 943 944 BENCH(g_u32 = 0, "mov:"); 945 BENCH(ASMAtomicXchgU32(&g_u32, 0), "xchg:"); 946 BENCH(ASMAtomicCmpXchgU32(&g_u32, 0, 0), "cmpxchg:"); 947 948 RTPrintf("Done.\n"); 949 } 950 923 951 924 952 int main(int argc, char *argv[]) … … 950 978 tstASMMemZeroPage(); 951 979 tstASMMath(); 980 tstASMBench(); 952 981 953 982 /*
Note:
See TracChangeset
for help on using the changeset viewer.