performance - int vs float arithmetic efficiency in Java -
I am writing an application that uses Djextra algorithms to find the minimum path in the graph. The weight of the nodes and edges in the graph is float
, so the algorithm is making many arithmetic on the float numbers. If I can convert all the load to int
s, can I get better time improving? Are int arithmetic operations fast in Java, then float those people?
I tried to write a simple benchmark to check it, but I am not satisfied with the results I get. Perhaps the compiler has adapted some parts of the program so that the results are not good for me.
Edit:
The problem I'm trying to solve is that the Recovery Area app should show the answers to a query as a set of keywords.
My data structure is a weighted guided graph. Looking at the set of lead nodes, I have to get a small tree which adds these nodes and shows the user's answer. The Weight Lifting Function is partly based on TF / IDF technology. The user does not know that the vods I assign to the nodes and the edges, he wants to see the answer related to the question that he had understood. Therefore, exact results are not required, only the calculation of the answers according to their weight is likely to be calculated. Just the original usage of the weighting function (as I mentioned it is based on TF / IDF) gives weight weight, so I used floats so far.
I hope this adds some background to the question.
You should never set yourself some performance goals with such things, and then Give the app a profile to see if it completes them.
Many times you can get amazing results; The time taken that is affected is absolutely affected by the numerical type, or that your algorithm is sub-symmetric.
And in relation to compiler optimization - they are the real and valid part of performance optimization.
If using Type A is theoretically faster than type B, but your compiler can adapt type B to be faster in a real scenario, then it is a valuable piece, Which is not the source of dissapointment.
Comments
Post a Comment