Google AdSense

Thursday, March 26, 2015

An example of using __rdtsc, __cpuid and __rdtscp to measure performance on Python

Descriptions

  • According to How to Benchmark Code Execution Times on Intel® IA-32 and IA-64 Instruction Set Architectures.
  • I wrote an extension module for Python to use these function. It is only tested on Python 3.3 x64 version. Python 2 should not be able to use it because the syntax for extension module is different between Python 2 and Python 3. It should be able to be used on x86 version if you change the compiler version and command.

Downloads

Results

  • loop_size: 0 >>>> variance(cycles): 943; max_deviation: 3882 ;min time: 237
    loop_size: 1 >>>> variance(cycles): 727; max_deviation: 3756 ;min time: 237
    loop_size: 2 >>>> variance(cycles): 906; max_deviation: 4209 ;min time: 237
    .........
    .........
    loop_size: 997 >>>> variance(cycles): 965; max_deviation: 3513 ;min time: 237
    loop_size: 998 >>>> variance(cycles): 825; max_deviation: 4125 ;min time: 237
    loop_size: 999 >>>> variance(cycles): 463; max_deviation: 3501 ;min time: 237

    total number of spurious min values = 20
    total variance = 1433
    absolute max deviation = 93813
    variance of variances = 38372287
    variance of minimum values = 5
    minimum value = 213

Comments

  • The result is not as good as C version. It could not get the minimum value in 100000 times test.

Resources

No comments:

Post a Comment