Created
October 19, 2010 23:29
-
-
Save kyleburton/635402 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public class Main { | |
public static void main ( String args [] ) { | |
int size = 392000000; | |
int sampleSize = 20000; | |
System.err.println("Start: allocation"); | |
int [] array = new int[size]; | |
System.err.println("Done: allocation"); | |
java.util.Random rnd = new java.util.Random(); | |
System.err.println("Start: population w/line numbers"); | |
for ( int ii = 0; ii < size; ++ii ) { | |
array[ii] = ii+1; | |
} | |
System.err.println("Done: population w/line numbers"); | |
System.err.println("Start: shuffle"); | |
for ( int ii = 0; ii < size; ++ii ) { | |
int newPos = rnd.nextInt(size); | |
int tmp = array[ii]; | |
array[ii] = array[newPos]; | |
array[newPos] = tmp; | |
} | |
System.err.println("Done: shuffle"); | |
for ( int ii = 0; ii < sampleSize; ++ii ){ | |
System.out.println("" + array[ii]); | |
} | |
} | |
} | |
// javac Main.java | |
// time java -Xmx4096M Main > results.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment