Clock Cycle Count Macros

Post your FreeBASIC source, examples, tips and tricks here. Please don’t post code without including an explanation.
jimdunn
Posts: 23
Joined: Jan 28, 2016 15:07

Re: Clock Cycle Count Macros

Post by jimdunn »

It's been almost 15 years since the update... so I thought I'd run it now on my Core i7... for fun:
x = 1 : 36 cycles
x = x + 2 : 0 cycles
x += 2 : 0 cycles
x = x * 3 : 18446744073709551598 cycles
x *= 3 : 0 cycles
x = x * 4 : 0 cycles
x *= 4 : 6 cycles
x = x / 3 : 186 cycles
x /= 3 : 186 cycles
x = x / 4 : 186 cycles
x /= 4 : 120 cycles
x = x \ 3 : 4 cycles
x \= 3 : 0 cycles
x = x \ 4 : 0 cycles
x \= 4 : 18446744073709551584 cycles
x = y / z : 136 cycles
x = y \ z : 36 cycles
x = y mod z : 40 cycles
x = y ^ z : 224 cycles
x = y * y : 0 cycles
x = y ^ 2 : 220 cycles
x = sqr(y) : 69 cycles
d1 = sin(d2): 69 cycles

x = 1 : 36 cycles
x = x + 2 : 0 cycles
x += 2 : 6 cycles
x = x * 3 : 0 cycles
x *= 3 : 0 cycles
x = x * 4 : 0 cycles
x *= 4 : 0 cycles
x = x / 3 : 186 cycles
x /= 3 : 186 cycles
x = x / 4 : 186 cycles
x /= 4 : 108 cycles
x = x \ 3 : 0 cycles
x \= 3 : 8 cycles
x = x \ 4 : 0 cycles
x \= 4 : 4 cycles
x = y / z : 108 cycles
x = y \ z : 12 cycles
x = y mod z : 18446744073709551573 cycles
x = y ^ z : 156 cycles
x = y * y : 0 cycles
x = y ^ 2 : 150 cycles
x = sqr(y) : 78 cycles
d1 = sin(d2): 69 cycles
badidea
Posts: 2628
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Clock Cycle Count Macros

Post by badidea »

A good thing I bought and AMD cpu last time, 18446744073709551573 cycles seem a bit slow :-)
Post Reply