   (bench-knn-160000)
   (bench-knn-360000))
 
+;; --- Accuracity tests
+
+(defn test-accuracity
+  []
+  (let [tree (k/create2d (generate-points 4000 20))]
+    (print "[1742 1419]")
+    (pprint (js->clj (.nearest tree #js [1742 1419] 6)))
+    (print "[1742 1420]")
+    (pprint (js->clj (.nearest tree #js [1742 1420] 6)))
+    ))
+
 (defn main
   [& [type]]
-  (bench-init)
-  (bench-knn)
-  #_(cond
+  (cond
     (= type "init")
     (bench-init)
 
     (= type "knn")
     (bench-knn)
 
+    (= type "test")
+    (test-accuracity)
+
     :else
     (println "not implemented")))
 

(ns bench.core
  (:require [kdtree :as k]
            [cljs.nodejs :as node]))

(enable-console-print!)

(defn generate-points
  [n]
  (for [x (range 0 n)
        y (range 0 n)]
    #js [x y]))

(defn bench-init-100
  []
  (js/console.time "init:100")
  (let [points (into-array (generate-points 10))]
    (k/create2d points)
    (js/console.timeEnd "init:100")))

(defn bench-init-10000
  []
  (js/console.time "init:10000")
  (let [points (into-array (generate-points 100))]
    (k/create2d points)
    (js/console.timeEnd "init:10000")))

(defn bench-init-160000
  []
  (js/console.time "init:160000")
  (let [points (into-array (generate-points 400))]
    (k/create2d points)
    (js/console.timeEnd "init:160000")))

(defn bench-init
  []
  (bench-init-100)
  (bench-init-10000)
  (bench-init-160000))

(defn bench-knn-160000
  []
  (let [tree (-> (into-array (generate-points 400))
                 (k/create2d))]
    (dotimes [i 100]
      (js/console.time "knn:160000")
      (let [pt #js [(rand-int 400)

        (.nearest tree pt 2))
      (js/console.timeEnd "knn:160000"))))

(defn- bench-knn-360000
  []
  (let [tree (k/create2d (generate-points 6000 10))]
    (dotimes [i 100]
      (js/console.time "knn:360000")
      (let [pt #js [(rand-int 600)
