sine and cosine

BlitzMax Forums/BlitzMax Beginners Area/sine and cosine

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

In those examples the random-calculation take up most of the time, so that "levels" the score quite a bit.

Local pcos#[360]
Local psin#[360]
Local ra#[10001,8]
For x = 0 To 359
	pcos[x] = Cos(x)
	psin[x] = Sin(x)
Next

For x=0 To 10000
For y=0 To 7
ra[x,y]=Rnd(0.0,359.0)
Next
Next

arraytime=0
mathtime=0

For y=0 To 10
sec = MilliSecs()
For x = 0 To 10000
 	n# = pcos[ra[x,0]]/psin[ra[x,1]]*pcos[ra[x,2]]/psin[ra[x,3]]+pcos[ra[x,4]]/psin[ra[x,5]]/pcos[ra[x,6]]/psin[ra[x,7]]
Next
lapse = MilliSecs() - sec 
arraytime=arraytime+lapse

sec = MilliSecs()
For x = 0 To 10000
	n# = Cos(ra[x,0])/Sin(ra[x,1])*Cos(ra[x,2])/Sin(ra[x,3])+Cos(ra[x,4])/Sin(ra[x,5])/Cos(ra[x,6])/Sin(ra[x,7])
Next
lapse = MilliSecs()-sec
mathtime=mathtime+lapse

Next

Print arraytime
Print mathtime



20 ms vs 80 ms

would compiler optimization still be an important factor in this test?