Last active
June 7, 2017 22:48
-
-
Save ilovesoup/c9aa2f1c5d51229c4dd160b399488c21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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