// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
package timerfun;

public class Timer {
    @FunctionalInterface
    public static interface CodeBlock {
        public void execute() throws Exception;
    }
    public static void time(String name, CodeBlock cb) throws Exception {
        long t1 = System.nanoTime();
        cb.execute();
        long t2 = System.nanoTime();
        System.out.printf("%s : %d\n", name, t2 - t1);
    }
}
