package ca.junctionbox.cljbuck.repl;

import clojure.lang.RT;

import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;

public class Main {
    public static void main(final String[] main) {
        System.out.println("Start you're engines!");
        long start = System.nanoTime();

        System.out.println(RT.var("clojure.core", "+").invoke(1, 2, 3));

        long finish = System.nanoTime();
        System.out.println("Clojure Load: " + (finish - start) + "ns");

        printGCStats();
    }

    public static void printGCStats() {
        long totalGarbageCollections = 0;
        long garbageCollectionTime = 0;

        for (GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) {

            long count = gc.getCollectionCount();

            if(count >= 0) {
                totalGarbageCollections += count;
            }

            long time = gc.getCollectionTime();

            if(time >= 0) {
                garbageCollectionTime += time;
            }
        }

        System.out.println("Total Garbage Collections: " + totalGarbageCollections);
        System.out.println("Total Garbage Collection Time (ms): " + garbageCollectionTime);
    }
}


@@ -56,16 +56,44 @@
 ng.RT;%0A%0A
+import java.io.IOException;%0A
 import j
@@ -257,62 +257,28 @@
 in) 
-%7B%0A        System.out.println(%22Start you're engines!%22);
+throws IOException %7B
 %0A   
@@ -323,35 +323,16 @@
         
-System.out.println(
 RT.var(%22
@@ -366,17 +366,16 @@
 1, 2, 3)
-)
 ;%0A%0A     
@@ -441,75 +441,24 @@
 tln(
-%22Clojure Load: %22 + (finish - start) + %22ns%22);%0A%0A        printGCStats(
+(finish - start)
 );%0A 

Remove readLine from repl:main for jar load performance output.