Hi all!
Following Gabriele Paoloni, 2010:
How to Benchmark Code Execution Times on Intel IA-32 and IA-64 Instruction Set Architectures. (
http://www.intel.com/content/dam/www/public/us/en/documents/white-papers/ia-32-ia-64-benchmark-code-execution-paper.pdf) I adapted to UEFI the measurement core:
mov r10, pBootServices
invoke [r10].EFI_BOOT_SERVICES.RaiseTPL,TPL_HIGH_LEVEL
mov Old_TPL, rax
CPUID
RDTSC
mov cycles_high , rdx
mov cycles_low , rax
; invoke measured_loop, j
RDTSCP
mov cycles_high1 , rdx
mov cycles_low1 , rax
CPUID
mov r10, pBootServices
invoke [r10].EFI_BOOT_SERVICES.RestoreTPL, Old_TPL
One Paoloni trick is to call (or not) a loop function then you can make estimations from minimum values using lineal regression:
measured_loop proc loops:qword
local i : qword
ForLp i, 0, loops
function_under_glass1
Next i
ret
measured_loop endp
The target code for the test is that used by Gunther in
Count cycles: test reports needed:
function_under_glass1 macro
fld qword ptr [numerator]
fdiv qword ptr [denominator]
fdiv qword ptr [denominator]
fdiv qword ptr [denominator]
fdiv qword ptr [denominator]
fstp qword ptr [result]
endm
To run the test, PC booted from a FAT32 formated USB.
*.efi files must be renamed to
BOOTX64.efi and copied to
/efi/boot/ directory in USB.
For first step the program is assembled with invocation to measured_loop commented (BenchmarkUEFI0.efi):
total number of spurious min values = 240
total variance = 0.5871
absolute max deviation = 8.000
variance of variances = 0.0002
lineal equation: total cycles =
30.8239 -
0.001 * repetitions
For second step the program is assembled making the invocation to measured_loop (BenchmarkUEFI2.efi):
total number of spurious min values = 1
total variance = 187.5673
absolute max deviation = 82.000
variance of variances = 25560.41
lineal equation: total cycles =
75.6068 +
18.0053 * repetitions
From these equations and rounding values you expect in this machine:
31 cycles overhead of measurement
45 cycles overhead of calling the loop function
18 cycles target code execution ----------- ------------------------------------------
94 cycles total measurement of single execution
Regards, HSE.