Jump to content
  • Advertisement
Sign in to follow this  
ryt

wich of these two is faster?

This topic is 3741 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Wich of these two is faster? This one: for(int i = 0; i < numberOfVerticesVertices; i++) { pVertices = vector3(0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(0, 0, 0, 0)); } or this one: memset(pVertices, 0, sizeof(vector3)*numberOfVerticesVertices);

Share this post


Link to post
Share on other sites
Advertisement
1. They don't do the same thing.
2. They're both useless, anyway.
3. It depends on the padding in the vector3 structure.
4. It also depends on the number of vertices.
5. It also depends on the vector3 constructor.
6. Assuming no padding and many vectors, the first will not be faster.
7. Use a profiler to determine the correct answer.

Share this post


Link to post
Share on other sites
I'm not used to VC++ Express (I use either VC++ Pro or g++), so I can't really tell. I heard good things about this , though.

Share this post


Link to post
Share on other sites
Quote:
Original post by ToohrVyk
1. They don't do the same thing.
2. They're both useless, anyway.

These are the points you should focus on. Why do you want to initialize the array?(or what are you trying to do?) When loading the 3d model you will overwrite those zeros anyway.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kambiz
Quote:
Original post by ToohrVyk
1. They don't do the same thing.
2. They're both useless, anyway.

These are the points you should focus on. Why do you want to initialize the array?(or what are you trying to do?) When loading the 3d model you will overwrite those zeros anyway.


In render look I change vertices of a mesh. I use += so they move relative to what position they had before. I must initialize to 0 so then I can recompute all vertices and have exact position. I dont want to leave positions untouched cos than to find new positions I would need to compute new positions and interpolate between new positions and old ones.

Share this post


Link to post
Share on other sites
Quote:
Original post by ferdekk
option with memset is faster.

when you use mmx,sse,sse2 opts, then much more faster.


thx, I didnt know that

Share this post


Link to post
Share on other sites
Quote:
Original post by ryt
In render look I change vertices of a mesh. I use += so they move relative to what position they had before. I must initialize to 0 so then I can recompute all vertices and have exact position. I dont want to leave positions untouched cos than to find new positions I would need to compute new positions and interpolate between new positions and old ones.


And? If you are doing this every frame, then instead of:
float f = 0.0f; 
f += delta;
use:
float f = delta;
and skip the initialize-to-zero altogether.

If you're doing this once at initialization time, the speed difference is pointless.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!