Here is a simplified example. Note that I chose simple types, but in an application I might have many more attribute
struct object
{
float a, b;
int c;
};
vector
or
vector a, b;
vector c;
In a game application where you access each attribute at least once, performance might vary. The game loop will run through the whole index, no matter what.
I know the first example is much more convenient (much easier to organize code with one single struct) and that it might depend on what the application is really doing, but isn't the second example more cache friendly ?
I know it's not the proper way to make an application at first with the Knuth premature optimization thing, but I'd just like to know... I've read this in a gamedev slide once and I'm wonder if it's true or not, and why.
No comments:
Post a Comment