Floats - Do you use the natives for calculating or the operators?
#5

Quote:
Originally Posted by Vince
View Post
I would very much like to see that benchmark because that seems a lot. I use the operators purely for aesthetic purposes and readability. Especially in longer calculations where the oversight would be easily lost due to the overabundance of brackets. That old GetDistanceBetweenPlayers function that people keep copying is a prime example.
The thing i tested was this:

PHP Code:
#define BENCHMARK(%0,%1,%2); \
    
{\
    new 
start GetTickCount();\
    for(new 
count 0count < %1count++)\
    {\
        %
0;\
    }\
    
printf("%s: %dms in %d iterations", %2GetTickCount() - start, %1);\
    }
#define TEST_ITERATIONS 10000000
BENCHMARK((1000.0 150.0) / 7.5TEST_ITERATIONS"operators - and /");
BENCHMARK(floatdiv(floatsub(1000.0150.0), 7.5), TEST_ITERATIONS"natives floatsub and floatdiv"); 
Ok, i changed this a little, but still the difference is about 10%

And yeah, i just realized how retarded that was, that i just generalized that the natives are faster, even though i didn't test them all and i just tested a specific case. in this case for example it is faster, but there were other cases where it was equally fast.

Maybe i am just too dumb to do benchmarking, that might be the case

Sorry for doing the thinking after the doing ...

But anyways, if the natives aren't faster, why would they exist, i have asked myself that.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)