package uk.co.johnjtaylor;

import java.util.Random;

public class Tester {
	private Random rand = new Random();
	
	public Tester() {
		
	}
	
	/**
	 * Generate an array of given length but only including a chosen range of numbers
	 * @param length Length of the generated array
	 * @param min Minimum number the integer values inside the array can have
	 * @param max Maximum number the integer values inside the array can have
	 */
	public int[] genArray(int length, int min, int max) {
		int[] result = new int[length];
		for(int i = 0; i < length; i++) {
			int nextNum = rand.nextInt((max-min) + 1) + min;
			result[i] = nextNum;
		}
		return result;
	}
	
	
	/**
	 * Generates an array of given length with no min/max
	 * @param length Length of the array
	 */
	public int[] genArray(int length) {
		int[] result = new int[length];
		for(int i = 0; i < length; i++) {
			int nextNum = rand.nextInt();
			result[i] = nextNum;
		}
		return result;
	}
	
	

}

@@ -119,39 +119,11 @@
 %0A%09%0D%0A
-%09public Tester() %7B%0D%0A%09%09%0D%0A%09%7D%0D%0A
 %09%0D%0A
+
 %09/**
@@ -953,23 +953,1329 @@
 esult;%0D%0A
-
 %09%7D%0D%0A%09%0D%0A
+%09/**%0D%0A%09 * Convenience method to get the current timestamp%0D%0A%09 * @return The current time in a UNIX timestamp%0D%0A%09 */%0D%0A%09public Long currTime() %7B%0D%0A%09%09return System.currentTimeMillis();%0D%0A%09%7D%0D%0A%09%0D%0A%09/**%0D%0A%09 * Returns the difference between two times (All in milliseconds)%0D%0A%09 * @param startTime The time the algorithm began%0D%0A%09 * @param endTime The time the algorithm finished%0D%0A%09 * @return The difference between start & end time%0D%0A%09 */%0D%0A%09public Long timeDiff(long startTime, long endTime) %7B%0D%0A%09%09return endTime - startTime;%0D%0A%09%7D%0D%0A%09%0D%0A%09%0D%0A%09/**%0D%0A%09 * Runs and times a sorting algorithm %0D%0A%09 * %0D%0A%09 * @param sortProgram A sorting object to be used to sort the array%0D%0A%09 * @param initialLength The initial length of the array used for testing (first iteration length)%0D%0A%09 * @param scale The factor of which to scale the length of the test array based on %22n%22.%0D%0A%09 * %09%09%09%09Where %22n%22 is the current iteration's length. E.g %22n*2%22 with an initial %0D%0A%09 * %09%09%09%09iteration length of 100 would be 200, then 400, then 800 etc. %0D%0A%09 * %09%09%09%09Supports single-operator changes of n: n*, n+, n%5E%0D%0A%09 * @param iterations The amount of test sorts to run%0D%0A%09 */%0D%0A%09public void test(Sort%3CInteger%3E sortProgram, int initialLength, String scale, int iterations) %7B%0D%0A%09%09int%5B%5D array = genArray(initialLength);%0D%0A%09%09for (int i = 0; i %3C iterations; i++) %7B%0D%0A%09%09%09%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%09%0D%0A%09%0D%0A
 %09%0D%0A%0D%0A%7D%0D%0A

Create basic structure, timing methods etc