Skip to content

Instantly share code, notes, and snippets.

@ilovesoup
Last active June 7, 2017 22:48
Show Gist options
  • Save ilovesoup/c9aa2f1c5d51229c4dd160b399488c21 to your computer and use it in GitHub Desktop.
Save ilovesoup/c9aa2f1c5d51229c4dd160b399488c21 to your computer and use it in GitHub Desktop.
import gnu.trove.list.array.TIntArrayList;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) throws Exception {
int n = 100000000;
for (int z = 0; z < 5; z++) {
TIntArrayList list = new TIntArrayList();
list.add(0);
long startTime = System.nanoTime();
for (int i = 0; i < n; i++) {
list.set(0, i);
}
System.out.println("TIntArrayList:" + (System.nanoTime() - startTime) / 1000000000.0);
ArrayList<Integer> alist = new ArrayList();
alist.add(0);
startTime = System.nanoTime();
for (int i = 0; i < n; i++) {
alist.set(0, i);
}
System.out.println("ArrayList:" + (System.nanoTime() - startTime) / 1000000000.0);
}
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment