Closed EdGarrity closed 5 years ago
2-D Java Arrays were slower then an array of vectors of vectors.
To test this, I did the following:
(defn load-datatable-2
"Loads the data file into a data table"
[]
(to-array-2d (drop 1
(with-open [in-file (io/reader "src/clojush/genesis/test-data/dataTable.csv")]
(->>
(csv/parse-csv in-file)
(cast-with #(Double/parseDouble %))
doall)
))))
(def datatable-2 (load-datatable-2))
I then ran the following tests (shown with results)
clojush.genesis.genesis> (time (get-cell-from-datatable 0 5)) "Elapsed time: 0.041641 msecs" 8.49834
clojush.genesis.genesis> (time (aget ^"[[J" (aget datatable-2 0) 5)) "Elapsed time: 0.116171 msecs" 8.49834
The Java Array was almost 3 times slower than the array of vectors of vectors.
Benchmark how Java Arrays could improve performance. See http://clojure-goes-fast.com/blog/java-arrays-and-unchecked-math/ for further details.