Advertisement

type optimization

Started by March 01, 2001 12:40 PM
2 comments, last by Thrump 23 years, 11 months ago
ball->location[1] += ball->velocity[1]*time-0.25f*time*time; ball->location[1] += ball->velocity[1]*time-0.25*time*time; One of these lines is 100+ times faster than the other. Can you tell which one?
Yes, but if you know one is faster, how comes you don''t know which one? And I don''t believe the 100x part, a few maybe, but not 100.

This wouldn''t be you homework would it?
There''s only one difference between the two lines, so it shouldn''t be difficult to work out which.
Gee Brain, what we gonna do tonight?
Advertisement
oops... the variables are all floats btw
Well, they were timed using the PS2 high-precision timers, and the difference in BUS cycles was around 13 for the first one, and 1500 for the 2nd one. No, not homework. I know the answer. It''s the one with the explicit typecast. I just thought it was neat that such a small change could bring about such a surprising difference in speed. Anyway, later.

This topic is closed to new replies.

Advertisement