Maybe I don't get yours point of view, to me, I suppose it's more personal preference.
Some members of this forum prefer units of time, others prefer clock cycles.
Alternating electrical energy in Brazil comes from the concessionaire at 60 hertz, in Europe I suppose it is 50 hertz. The period is the inverse (reciprocal) of the frequency, and in 1 second 60 turns are necessary (or 50, or N). An incandescent lamp blinks 60 times per second in Brazil, but for our eyes it is constant, we do not see it blink 60 times(clock cycles) in 1 second, or if you prefer, 1/60 = 0,016666667 seconds to each blink.
We can never have an accuracy when measuring something, just an approximation. Be it the weight of a person, be it using a ruler with units of centimeters but not millimeters, be it the bee going back and forth over the steps of two people walking to meet each other.
A clock pulse comes from the vibration of the quartz crystal which is multiplied by a given operating factor.
The processor is always doing something, always.
By interference in the results I mean internal reordering of the instructions to be executed, failures when reading data that is not present in the cache, instructions executed out of order, instructions in the queue to be executed, serializations, sincronization, instructions per cycle, ... .
If we have the clock cycles and divide it by the operating frequency of the cpu we will be able to measure it in time.
So, whats wrong with this instruction (rdtsc)? Where does the time measured in computers come from?
Why to some users here time measure is prefered instead of clock cycles?
lscpu
CPU MHz: 800,404
Max CPU MHz: 4000,0000 (at one second it proceds 4000000 cycles)
Min CPU MHz: 800.0000
The CPU operating at low operating frequency: 800 MHz
time: 0.000000175 seconds
130 cycles 146 cycles 140 cycles 128 cycles 144 cycles
The cpu operating at 4ghz frequency.
cpufreq-set -c 0 -g performance
cpufreq-set -c 0 -d 4000000
time: 0.000000007 seconds
28 cycles 28 cycles 26 cycles 28 cycles 28 cycles
;mfence ;lfence ;sfence
;lea rax,@F
;prefetcht0 [rax]
;prefetcht1 [rax]
;prefetcht2 [rax]
;prefetchnta [rax]
;prefetchw [rax]
;prefetchwt1 [rax]
;xor eax,eax
;cpuid
;rdtsc
rdtscp
mov r12d,eax
mov r13d,edx
rdtscp
sub eax,r12d
sbb edx,r13d
shl rdx,32
or rdx,rax
invoke printf,CStr("%llu ciclos",10),rdx
edited - changed code