Is sqrt still slow in Delphi 2009?

Is sqrt still slow in Delphi 2009?

Are old tricks useful (lookup table, approximate functions)?

+4
source share
3 answers

If you are dealing with a small set of really large numbers, then the lookup table will always be faster. Although, if you are dealing with a large set of small numbers, then even a slow procedure can be faster than maintaining a large table.

I looked in System.pas (where SQRT is located), and although there are several blocks marked as licensed from the Fastcode project, there is no SQRT . In fact, it just makes a call to the FSQRT assembly, so it most likely hasn't changed. Therefore, if at some point it was relatively slow, it is most likely still slow (although your processor can be much faster and optimized for this now ...)

My recommendation is to look at your usage and test.

+5
source

Many moons ago I had an application calculated distance for sorting vectors. I realized that sorting by non-sqrt-ed values ​​was the same, so I completely skipped it. Sorted by distance ^ 2 and saved some time.

+3
source

My answer to efficiency questions is to apply the simplest method first and then optimize it later. Performing an operation quickly, when it is not necessary to be so fast, seems silly in the first place.

I am distracted, however, because my answer is about the effectiveness, not the historical aspects of your question.

+1
source

All Articles