用 __rdtsc,__cpuid 和 __rdtscp 測量效能的解析度
說明
- 根據 How to Benchmark Code Execution Times on Intel® IA-32 and IA-64 Instruction Set Architectures 這篇文章
下載
結果
- 每個 loop 執行 1000000 次,關閉大部分會影響測量的功能
Loading hello module...
loop_size:0 >>>> variance(cycles): 56; max_deviation: 2320 ;min time: 44
loop_size:1 >>>> variance(cycles): 3; max_deviation: 196 ;min time: 44
loop_size:2 >>>> variance(cycles): 3; max_deviation: 52 ;min time: 44
loop_size:3 >>>> variance(cycles): 3; max_deviation: 200 ;min time: 44
loop_size:4 >>>> variance(cycles): 35; max_deviation: 1272 ;min time: 44
loop_size:5 >>>> variance(cycles): 41; max_deviation: 1436 ;min time: 44
loop_size:6 >>>> variance(cycles): 4; max_deviation: 48 ;min time: 44
loop_size:7 >>>> variance(cycles): 23705; max_deviation: 48212 ;min time: 44
loop_size:8 >>>> variance(cycles): 0; max_deviation: 64 ;min time: 48
loop_size:9 >>>> variance(cycles): 1183; max_deviation: 10424 ;min time: 48
loop_size:10 >>>> variance(cycles): 62; max_deviation: 1504 ;min time: 48
loop_size:11 >>>> variance(cycles): 532; max_deviation: 7108 ;min time: 48
.........
.........
loop_size:994 >>>> variance(cycles): 107645; max_deviation: 48216 ;min time: 2024
loop_size:995 >>>> variance(cycles): 238464; max_deviation: 109996 ;min time: 2028
loop_size:996 >>>> variance(cycles): 13831; max_deviation: 31548 ;min time: 2028
loop_size:997 >>>> variance(cycles): 26722152; max_deviation: 1633788 ;min time: 2032
loop_size:998 >>>> variance(cycles): 39271; max_deviation: 56508 ;min time: 2032
loop_size:999 >>>> variance(cycles): 2648; max_deviation: 10948 ;min time: 2036
total number of spurious min values = 0
total variance = 8741630
absolute max deviation = 111584704
variance of variances = 14133967985047
variance of minimum values = 335600
- 每個 loop 執行 1000000 次,關閉大部分會影響測量的功能
Loading hello module...
loop_size:0 >>>> variance(cycles): 6; max_deviation: 405 ;min time: 42
loop_size:1 >>>> variance(cycles): 4; max_deviation: 27 ;min time: 42
loop_size:2 >>>> variance(cycles): 6; max_deviation: 435 ;min time: 42
loop_size:3 >>>> variance(cycles): 4; max_deviation: 39 ;min time: 42
loop_size:4 >>>> variance(cycles): 4; max_deviation: 45 ;min time: 42
loop_size:5 >>>> variance(cycles): 4; max_deviation: 108 ;min time: 42
loop_size:6 >>>> variance(cycles): 7; max_deviation: 108 ;min time: 42
loop_size:7 >>>> variance(cycles): 11; max_deviation: 411 ;min time: 42
loop_size:8 >>>> variance(cycles): 8; max_deviation: 426 ;min time: 45
loop_size:9 >>>> variance(cycles): 112; max_deviation: 3159 ;min time: 45
loop_size:10 >>>> variance(cycles): 16; max_deviation: 489 ;min time: 45
loop_size:11 >>>> variance(cycles): 143; max_deviation: 2661 ;min time: 45
.........
.........
loop_size:994 >>>> variance(cycles): 2332; max_deviation: 2376 ;min time: 1932
loop_size:995 >>>> variance(cycles): 2278; max_deviation: 2352 ;min time: 1935
loop_size:996 >>>> variance(cycles): 2360; max_deviation: 2403 ;min time: 1935
loop_size:997 >>>> variance(cycles): 2955; max_deviation: 6282 ;min time: 1938
loop_size:998 >>>> variance(cycles): 2544; max_deviation: 2415 ;min time: 1938
loop_size:999 >>>> variance(cycles): 2474; max_deviation: 2502 ;min time: 1941
total number of spurious min values = 1
total variance = 8162
absolute max deviation = 91305
variance of variances = 510271300
variance of minimum values = 305686
心得
- 看起來跟內嵌組譯語言的版本也幾乎都一樣,就是稍微快了一點點
資源
沒有留言:
張貼留言