Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Use bitpacker or not? EDUCATED Opinions?
#1
Ok, here's the deal.

I have an object instance attribute array. It's an integer array.

I have a further object attribute array, also an integer array.

The second array shows the start and end positions of each object instance:

Code:
objectInstanceSequence(1) = 1
objectInstanceSequence(2) = 6
objectInstanceSequence(3) = 2
objectInstanceSequence(4) = 9
objectInstanceSequence(5) = 3

objectInstanceSequence.end(0) = 0
objectInstanceSequence.end(1) = 5

So the attribute list for object 1 is:
1 6 2 9 3

BUT, to make my system more flexible, I want to be able to use individual bits. (also the same for similar array pairs) The objectInstanceSequence.end() array will use bits, not integer arrays. The objectInstanceSequence() array will be the same.

I was worried before that using individual bits slows down the access time, but do you think it's really significant compared to space savings? And if you use more memory, aren't you using more time to access parts of memory to get where you want to be? So is this a good or bad idea, and why?
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#2
Quote:I was worried before that using individual bits slows down the access time, but do you think it's really significant compared to space savings? And if you use more memory, aren't you using more time to access parts of memory to get where you want to be? So is this a good or bad idea, and why?

Depends what you want to do with it, if the first array is used mostly to hold integer values then the space savings would be neglible, if you are storing lots of bit values then it may be worth the speed tradeoff to get the extra storage space.

But, why not try out my memory routines: http://www.qbnz.com/pages/downloads/util...memory.zip
They allow you to create linked-lists quite easily (which seems to be what you are doing here) and can also be used for loading/storing single bits at a time. It also gives you a bit more flexibility, with your approach it is difficult to add a new member to the first array, all of the elements ahead of it will need to be moved forward one because the second array requires all the elements to be grouped together.
esus saves.... Passes to Moses, shoots, he scores!
Reply
#3
Thanks for trying to help me, but I don't think your routine will help.

The types and length of each type are defined from text files in my scheme, so I don't think this will work.

Also, memory freeing and allocation. It's not really freeing anything, just removing the pointer. I can do that with arrays, too. :|
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#4
I think you can compromise the speed =) 'cause I feel u cant easily change the amount of mem you can use but you can use a 3.2GHz P4 with HT :lol:
Reply
#5
Hm.. yeah, but I'm still using 400mhz.

Well this part of the code won't be used THAT often, I guess.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#6
Then i dont think it will cause much of a difference =)
Reply
#7
I use half-INTs to store object sprites in Quest for a king. The problem with it is that there is no bitshifter in QB, so you must use ANDs & multiplies to extract the numbers, so the speed drop is quite noticeable unless you're only using it rarely. Personally, I found that the memory saved was substantial enough to justify the hit, but if you don't have speed to spare like I did, it's a bad way to go -- every access becomes an automatic speed hit.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)