> I am getting ~25 millisecond performance except in 2 cases where 40
> millisecs are obtained (but these might be optimized also). If arrays
> are used, it would probably get faster.
You may be searching Very Large datasets, or be running on a Very Slow CPU (a
phone, say). But if not then that sounds a little on the slow side to me.
That's about a million cycles to do a lookup which shouldn't be much worse in
practise than log(N). I'd expect[*] a couple of orders of magnitude more speed
at least.
([*] That's to say my gut feeling is that that should be possible, and I would
want to know /why/ if I wasn't achieving it. Always assuming that I cared
about performance -- which seems likely in this case.)
> - On inquiry, 2 binary searches are performed, first on the collapsed x
> values and then, using the index into the ylist, on only the y values
> which have the same xValue. The z is returned when the y has been "found".
What happens if the closest point doesn't match exactly in X ? E.g you have Z
values for points:
(10, 12)
(11, 1000)
and you try to find the closest point to (10, 1000). I may well have
misunderstood your algorithm description, but I /think/ it would come up with
(10, 12) rather than the (much!) closer (11, 1000).
-- chris
Roedy Green - 09 Mar 2006 18:04 GMT
On Thu, 9 Mar 2006 10:50:46 -0000, "Chris Uppal"
<chris.uppal@metagnostic.REMOVE-THIS.org> wrote, quoted or indirectly
quoted someone who said :
>> I am getting ~25 millisecond performance except in 2 cases where 40
>> millisecs are obtained (but these might be optimized also). If arrays
>> are used, it would probably get faster.
One thing to think about is how much do you hop all over RAM in your
lookup. You may be triggering some page faults.
Try pruning away anything else using RAM. Think if it is possible to
do the majority of your lookup process on smaller compact tables.
It can be as simple as separating the lookup info from the data, so
you are not paging in data during the early stages of the lookup.
As always you want to profile to find out where the time is going. It
could be chewed up in frequent GC. A bigger heap may be all you need.
see http://mindprod.com/jgloss/profiler.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.