Well now that I got it working, I wanted to do some timing on accessing arrays in Max in various ways, and I decided to check the speed against Bitzplus.
Here is the code for Max:
And the code for Blitzplus:
Max is the winner here:
Max: 27
BP: 78
Replacing the inner loop with the following, gets the following results:
Max: 23
BP: 86
And using a two dimensional array, instead of doing the multiplication manually:
Max: 43
BP: 94
What?!
Compare those results to the first test, and you'll see the times are significantly GREATER, even though in both instances, a single multiplication and addition should be being done each array access.
Mark? Explanation pelase?
Well, at the very least, I've learned Max is about 3x as fast as BP when accessing arrays.
Here is the code for Max:
Local A:Int[10000] StartTime = MilliSecs() For Loop = 1 To 1000 For Y = 0 To 99 For X = 0 To 99 A[Y*100 + X] = 10 Next Next Next EndTime = MilliSecs() Print "Totaltime = " + (EndTime-StartTime)
And the code for Blitzplus:
Dim A(10000) StartTime = MilliSecs() For Loop = 1 To 1000 For Y = 0 To 99 For X = 0 To 99 A(Y*100 + X) = 10 Next Next Next EndTime = MilliSecs() Print "Totaltime = " + (EndTime-StartTime) WaitKey()
Max is the winner here:
Max: 27
BP: 78
Replacing the inner loop with the following, gets the following results:
For Y = 0 To 99 Y2 = Y*100 For X = 0 To 99 A(Y2 + X) = 10 Next Next
Max: 23
BP: 86
And using a two dimensional array, instead of doing the multiplication manually:
Max: 43
BP: 94
What?!
Compare those results to the first test, and you'll see the times are significantly GREATER, even though in both instances, a single multiplication and addition should be being done each array access.
Mark? Explanation pelase?
Well, at the very least, I've learned Max is about 3x as fast as BP when accessing arrays.