@@ -0,0 +1,2858 @@
+package main.utility;%0A%0A/**%0A * A helper class that can be useful for timing specific aspects of an algorithm.%0A * Idea:%0A *   long start = System.nanoTime();%0A *   long end = System.nanoTime();%0A *   TimeCounter.time1 += end - start;%0A *   TimeCounter.iterations++;%0A */%0Apublic class TimeCounter %7B%0A    public static long timeA;%0A    public static long timeB;%0A    public static long timeC;%0A    public static long timeD;%0A    public static long timeE;%0A    %0A    public static int iterations;%0A    %0A    private static boolean isFrozen;%0A    public static long timeA_freeze;%0A    public static long timeB_freeze;%0A    public static long timeC_freeze;%0A    public static long timeD_freeze;%0A    public static long timeE_freeze;%0A    public static int iterations_freeze;%0A    %0A    public static void reset() %7B%0A        unfreeze();%0A        timeA = 0;%0A        timeB = 0;%0A        timeC = 0;%0A        timeD = 0;%0A        timeE = 0;%0A        iterations = 0;%0A    %7D%0A    %0A    /**%0A     * Temporarily freeze the counter by storing the values.%0A     */%0A    public static void freeze() %7B%0A        if (isFrozen) return;%0A        timeA_freeze = timeA;%0A        timeB_freeze = timeB;%0A        timeC_freeze = timeC;%0A        timeD_freeze = timeD;%0A        timeE_freeze = timeE;%0A        iterations_freeze = iterations;%0A        %0A        isFrozen = true;%0A    %7D%0A    %0A    /**%0A     * Unfreeze the counter %0A     */%0A    public static void unfreeze() %7B%0A        if (!isFrozen) return;%0A        tryRetrieveFrozenValues();%0A        %0A        isFrozen = false;%0A    %7D%0A    %0A    private static void tryRetrieveFrozenValues() %7B%0A        if (!isFrozen) return;%0A        timeA = timeA_freeze;%0A        timeB = timeB_freeze;%0A        timeC = timeC_freeze;%0A        timeD = timeD_freeze;%0A        timeE = timeE_freeze;%0A        iterations = iterations_freeze;%0A    %7D%0A%0A    private static double toSecs(long value) %7B%0A        return value / 1000000000.;%0A    %7D%0A%0A    private static double toSecsPer(long value) %7B%0A        return value / 1000000000. / iterations;%0A    %7D%0A%0A    public static void print() %7B%0A        tryRetrieveFrozenValues();%0A        %0A        System.out.println(%22Time A: %22 + toSecs(timeA));%0A        System.out.println(%22Time B: %22 + toSecs(timeB));%0A        System.out.println(%22Time C: %22 + toSecs(timeC));%0A        System.out.println(%22Time D: %22 + toSecs(timeD));%0A        System.out.println(%22Time E: %22 + toSecs(timeE));%0A%0A        System.out.println(%22Iterations: %22 + iterations);%0A    %7D%0A%0A    public static void printAverage() %7B%0A        tryRetrieveFrozenValues();%0A        %0A        System.out.println(%22Time A: %22 + toSecsPer(timeA));%0A        System.out.println(%22Time B: %22 + toSecsPer(timeB));%0A        System.out.println(%22Time C: %22 + toSecsPer(timeC));%0A        System.out.println(%22Time D: %22 + toSecsPer(timeD));%0A        System.out.println(%22Time E: %22 + toSecsPer(timeE));%0A%0A        System.out.println(%22Iterations: %22 + iterations);%0A    %7D%0A    %0A    %0A%7D%0A

Add TimeCounter.java, a utility class to make timing specific parts of an algorithm slightly more convenient