KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I guess they're the same thing but Clojure uses the Array class to manipulate. Anyway, I've been told that in Clojure if you really need speed then you can use arrays but between the following programs the Java version is much faster (time (let [data (int-array 100000000)] (dotimes [q 100000000] (aset-int data q q)))) _ public class Array{ public static void main(String[] args){ long start = System.currentTimeMillis(); int[] data = new int[100000000]; for(int q = 0;q < data.length;q++){ data[q] = q; } System.out.println(System.currentTimeMillis() - start); } } In contrast, this Clojure program that uses the IntBuffer class is almost as fast as the Java code (time (let [data (IntBuffer/allocate 100000000)] (dotimes [q 100000000] (.put data q q))))
Tags (comma-separated)
Save Edits
Cancel