quick poll - precalc sin & cos or perform every frame ?

BlitzPlus Forums/BlitzPlus Programming/quick poll - precalc sin & cos or perform every frame ?

Your above post is massively flawed.

You are batching the operations. That's not at all what happens in a game engine. Interleaving the commands is way more realistic, because rarely would people perform a million trig functions, only to THEN draw something.

And on Blitz3D and BlitzPlus the results become exactly the same. Pointing out the fact that the weakest link of your test is actually in the drawing of the squares, and not the trig functions.

That's exactly what I've been trying to tell you, that in an actual game, with realistic function calls, the net effect of lookups is going to be worse or negligible compared with just using the functions built in to Blitz. Just interspersing the array lookups with even one function call totally ruins any advantage you would have got from hogging the L1 cache with just the array.

Graphics 640,480,32,2
N=100000
Dim Sin2#(360)
Dim Cos2#(360)
For a=0 To 359
    Sin2#(a)=Sin(a)
    Cos2#(a)=Cos(a)
Next
;Change this to switch test
Const UseLookup=0
starmill = MilliSecs()
If uselookup=0 Then
For t = 1 To N
x1#=Sin#(Rnd(0,359))
x2#=Cos#(Rnd(0,359))
Rect 50,50,100,100
Next
Else
For t = 1 To N
x1#=Sin2#(Rnd(0,359))
x2#=Cos2#(Rnd(0,359))
Rect 50,50,100,100
Next
End If
result=MilliSecs() - starmill
Text 0,0,result
Flip
WaitKey()
End