Posted on January 19, 2009, 9:26 pm, by eruskin, under
Programming.
I’ve just updated my prior article on virtual function overhead with corrected timing numbers — I hadn’t noticed that my CPU cycle counts were only 32 bits wide so timings of more than 2secs would wrap back around to zero. If you want to run this test on your own hardware, I’ve put my code […]
Posted on January 19, 2009, 9:30 am, by eruskin, under
Programming.
Whenever I work with virtual functions I find myself wondering: how much is it costing me to perform all these vtable lookups and indirect calls? The usual truism is that computers are so fast now that it doesn’t matter and that the idea of virtuals being a problem is just another myth. Our beloved Xenon […]
Posted on January 13, 2009, 1:32 pm, by eruskin, under
Programming.
For best float-to-int conversion speed, specify the compiler flag /arch:SSE2 to assume the availability of SSE2 opcodes.
Posted on January 12, 2009, 9:00 am, by eruskin, under
Programming.
The seemingly simple act of assigning an int to a float variable, or vice versa, can be astonishingly expensive. In some architectures it may cost 40 cycles or even more! The reasons for this have to do with rounding and the load-hit-store issue, but the outcome is simple: never cast a float to an int […]
Posted on January 4, 2009, 10:00 am, by eruskin, under
Programming.
Branching on floating-point values can be a significant performance penalty. In some cases, using the ternary operator ?: or substituting a conditional-move operator like fsel allows you to make your function branchless and run much faster.