Coder Social home page Coder Social logo

Comments (2)

phishman3579 avatar phishman3579 commented on May 18, 2024

From the readme of this site "The code isn't overly-optimized but is written to be correct and readable."

In other words, I know. The code is meant to be more readable than performant.

from java-algorithms-implementation.

phishman3579 avatar phishman3579 commented on May 18, 2024

@hoerup I did a quick test and I am seeing similar performance between the two implementations with my implementation quite a bit quicker than Geocode at nearest neighbor search. Can you show me what you did to test the performance?

Data Structure (25600 items) Add time NNS time
My KdTree 39.58 ms 70.43 ms
GeoCode KdTree 35.69 ms 243.15 ms

Testing code below...

my kd tree construction time.

        long beforeAddTime = System.nanoTime();
        KdTree<KdTree.XYZPoint> tree = new KdTree<KdTree.XYZPoint>(points, 2); // 2 since we only care about two dimensions (x,y) 
        long afterAddTime = System.nanoTime();

Geocode construction time

        long beforeAddTime = System.nanoTime();
        KDTree<XYZPoint> tree = new KDTree<XYZPoint>(points); 
        long afterAddTime = System.nanoTime();

My NNS time:

        long beforeContainsTime = System.nanoTime();
        for (KdTree.XYZPoint p : points) {
            //boolean r = tree.contains(p);
            Collection<KdTree.XYZPoint> r = tree.nearestNeighbourSearch(1, p);
            assertTrue("Point not found.", p, tree, (r.size()==1 && r.iterator().next().equals(p)));
        }
        long afterContainsTime = System.nanoTime();

GeoCode NNS time:

        long beforeContainsTime = System.nanoTime();
        for (XYZPoint p : points) {
            XYZPoint r = tree.findNearest(p);
            assertTrue("Point not found.", p, tree, r.equals(p));
        }
        long afterContainsTime = System.nanoTime();

All times measured via ((after-before)/points)

from java-algorithms-implementation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.