Banks vs Arrays

Blitz3D Forums/Blitz3D Programming/Banks vs Arrays

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.

Are arrays faster than banks? I've always thought otherwise, but while making my own bank library, I decided to test it.

Graphics 640,480,0,2

SeedRnd MilliSecs()

;Bank
Bank = CreateBank(100000 * 4)

;Array
Dim Array(100000)


;Bank-test
Start = MilliSecs()
	For x = 1 To 1000

		For i = 1 To 100000
			PokeFloat(Bank, (i-1)*4, Rnd(0.0, 100000.0))
		Next
	
		;For i = 0 To 399999 Step 4
		;	PokeFloat(Bank, i, Rnd(0.0, 100000.0))
		;Next
	
		For i = 1 To 100000
			Temp = PeekFloat(Bank, (i-1)*4)
		Next

		;For i = 0 To 399999 Step 4
		;	Temp = PeekFloat(Bank, i)
		;Next

	Next

Time = MilliSecs() - Start


;Array-test
Start = MilliSecs()
	For x = 1 To 1000

		;Dim Array(100000)

		For i = 1 To 100000
			Array(i) = Rnd(0.0, 100000.0)
		Next

		For i = 1 To 100000
			Temp = Array(i)
		Next

	Next

Time2 = MilliSecs() - Start

Print "Bank: Time " + Time + " ms"
Print "Dim:  Time " + Time2 + " ms"
WaitKey


I get around 6500ms for bank and around 5000-5300ms for array. Have I made some mistake in the test-code?

The commented out ways of calculating the position within the bank don't affect the results much. Array is faster even if it is re-dimmed every 'x'-loop