BufferedWriter timSigOut = new BufferedWriter(new FileWriter("/home/stas/Projects/stableSort/timSig.dat"));
BufferedWriter insertionSigOut = new BufferedWriter(new FileWriter("/home/stas/Projects/stableSort/insertionSig.dat"));
DescriptiveStatistics timSort;
DescriptiveStatistics insertionSort;
int tryies = 200;
int arrayLength = 0;
for (; arrayLength < 1000; ++arrayLength) {
int[] coSort = nextArray(arrayLength, bitsStreamGenerator);
timSort = new DescriptiveStatistics();
insertionSort = new DescriptiveStatistics();
for (int i = 0; i < tryies; ++i) {
int[] t1 = nextArray(arrayLength, bitsStreamGenerator);
int[] t2 = t1.clone();
long start = System.currentTimeMillis();
ArraysUtils.timSort(t1, coSort);
long stop = System.currentTimeMillis();
timSort.addValue(stop - start);
start = System.currentTimeMillis();
ArraysUtils.insertionSort(t2, coSort);
stop = System.currentTimeMillis();
insertionSort.addValue(stop - start);
}
timMeanOut.write(arrayLength + "\t" + timSort.getMean() + "\n");
insertionMeanOut.write(arrayLength + "\t" + insertionSort.getMean() + "\n");
timMaxOut.write(arrayLength + "\t" + timSort.getMax() + "\n");
insertionMaxOut.write(arrayLength + "\t" + insertionSort.getMax() + "\n");
timSigOut.write(arrayLength + "\t" + timSort.getStandardDeviation() + "\n");
insertionSigOut.write(arrayLength + "\t" + insertionSort.getStandardDeviation() + "\n");
}
timMeanOut.close();
insertionMeanOut.close();
timMaxOut.close();
insertionMaxOut.close();