Memory banks versus integer data

Blitz3D Forums/Blitz3D Programming/Memory banks versus integer data

Yue(Posted 2015) [#1]
Graphics3D ( 800, 600, 32, 2 )


miBanco% = CreateBank()

PokeByte miBanco%, 0,255

datoByte% = PeekByte (miBanco%,0)


FreeBank miBanco%


miNumero% = 255
Repeat 
	
	
	RenderWorld 
	
	Text 0,0, datoByte%
	Text 0, 10, miNumero%
	
	Flip 
	
	
	
Until KeyHit(1)



If you use a memory for storing a number not exceeding the data type byte, 255, I'm saving memory ?, I ask that the integer data type has a higher rank.


xlsior(Posted 2015) [#2]
You'd save memory, but IIRC Blitz can handle integers faster than the other datatypes, so using bytes may be very slightly slower.


Yue(Posted 2015) [#3]
I thought the memory banks were much faster.

In such a case when retrieving the data type byte bank, move to a integer variable and achievement does not understand what is the advantage of a bank.


datoByte% = PeekByte (Mibanco%, 0)



Matty(Posted 2015) [#4]
The advantage of a bank is you can store more than a single value....

Useful for reading files into memory and then parsing through them.....

Useful for returning multiple values from a function (store them in a bank and return the bank handle)

The main drawback is that you have to get your bank offsets correct otherwise you will end up reading/writing junk data to/from the bank....


Rroff(Posted 2015) [#5]
Memory banks can be faster when dealing with blocks of memory but AFAIK generally are inefficient for high frequency retrieval of discrete values.


RemiD(Posted 2015) [#6]
I have used a bank in one case when i needed to store the heights (between 0 and 255) of a huge terrain. Because there is no way in Blitz3d to create a dim array with bytes instead of integers, i used a bank with bytes to store these heights without taking too much memory...


_PJ_(Posted 2015) [#7]
I recently had to do something extremely similar to RemiD and yeah, it can save memory because you're using 1/4 the bytes, but may not necessarily be faster due to extra time in processing and locating the data...

It all really depends on the amount of data and the frequency/complexity of the processes which use and manipulate it.

Anyway, coincidentally, I recently thought I'd share this:
http://www.blitzbasic.com/codearcs/codearcs.php?code=3171


RemiD(Posted 2015) [#8]
@_PJ_>>interesting, i will take a look when i have more time.

You may be interested in this :
http://www.blitzbasic.com/Community/posts.php?topic=101699
(not sure if this works correctly)


_PJ_(Posted 2015) [#9]
I'll have a look over that in more detail this evening.
Seems pretty intriguing!