[PATCH] swap pow for sqrt to save time

Hi, I was looking at hprof output for mkgmap after having processed quite a large map and about 40% of the time was being spent in Math.pow() - the attached patch swaps out the pow(x, 0.5) for sqrt(x) and the run time drops from 130 seconds to around 83! Is there any reason not to go for the sqrt version? If not, it's well worth making the change. Cheers, Mark

I was looking at hprof output for mkgmap after having processed quite a large map and about 40% of the time was being spent in Math.pow() - the attached patch swaps out the pow(x, 0.5) for sqrt(x) and the run time drops from 130 seconds to around 83! Is there any reason not to go for the sqrt version? If not, it's well worth making the change.
Did anyone think this was a bad idea? If not, I shall commit that change in the morning.

On Mon, Feb 16, 2009 at 11:15:29PM +0000, Mark Burton wrote:
I was looking at hprof output for mkgmap after having processed quite a large map and about 40% of the time was being spent in Math.pow() - the attached patch swaps out the pow(x, 0.5) for sqrt(x) and the run time drops from 130 seconds to around 83! Is there any reason not to go for the sqrt version? If not, it's well worth making the change.
Did anyone think this was a bad idea? If not, I shall commit that change in the morning.
It didn't make a lot of difference with the file I tried it with, but seems like the right thing to do. ..Steve
participants (2)
-
Mark Burton
-
Steve Ratcliffe