[ 
https://issues.apache.org/jira/browse/GEOMETRY-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17526158#comment-17526158
 ] 

Matt Juntunen commented on GEOMETRY-146:
----------------------------------------

It turns out that my instincts on the performance of {{neighborEntries}} were 
incorrect and I am not able to find a performance boost over just using 
{{nearToFar}} or even just iterating through the entire map. Below are the JMH 
results for the best implementation I could come up with.

||Benchmark||(dist)||(randomSeed)||(shape)||Mode||Cnt||Score||Error||Units||
|neighborEntries|random|1|block|avgt|5|18078272.739|± 2855877.430|ns/op|
|neighborEntriesFullBaseline|random|1|block|avgt|5|3953413.160|± 
1299435.732|ns/op|
|neighborEntriesFullStreamBaseline|random|1|block|avgt|5|19190180.574|± 
3775274.018|ns/op|
|neighborEntriesNearToFarBaseline|random|1|block|avgt|5|13143387.077|± 
2344194.490|ns/op|
|neighborEntryIterable|random|1|block|avgt|5|15025352.786|± 3978281.128|ns/op|

- {{neighborEntries}} - supposedly "optimized" method
- {{neighborEntriesFullBaseline}} - iterating through the entire map and 
checking the distance for each entry
- {{neighborEntriesFullStreamBaseline}} - filtering a stream over the map entry 
set
- {{neighborEntriesNearToFarBaseline}} - iterating over the {{nearToFar}} 
collection and breaking out of the loop when the max distance is passed
- {{neighborEntryIterable}} - iterator version of {{neighborEntries}}

Based on these results, I'm going to remove {{neighborEntries}} from the API. 
There isn't a performance boost and the functionality can be implemented in 
terms of the other methods.


> PointSet/Map closest points
> ---------------------------
>
>                 Key: GEOMETRY-146
>                 URL: https://issues.apache.org/jira/browse/GEOMETRY-146
>             Project: Commons Geometry
>          Issue Type: New Feature
>            Reporter: Matt Juntunen
>            Priority: Major
>             Fix For: 1.1
>
>
> Add methods to the new {{PointSet}} and {{PointMap}} interfaces to allow 
> querying of points in order of distance from a query point.
> {code:java}
> PointSet<P> {
>     // find the closest point to pt or null if empty 
>     P closest(P pt);
>     // iterate through points in order, with points closest to pt coming first
>     Iterable<P> closestFirst(P pt);
>     // find the farthest point from pt or null if emtpy
>     P farthest(P pt);
>     // iterate through point in order, with points farthest from pt coming 
> first
>     Iterable<P> farthestFirst(P pt);
> }
> {code}
> {{PointMap}} should have similar methods providing access to the map keys and 
> entries.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to