// 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) 
public class ExceptionOverhead {
    private final static int N = 1000000;
    public static void main(String[] args) {
        long t1 = System.currentTimeMillis();
        int n = 0;
        for(int i = 0; i < N; i++) {
            try {
                throw new Exception("Test");
            } catch(Exception ex) {
                n++;
            }
        }
        if(n != N) throw new RuntimeException("Ooops");
        long t2 = System.currentTimeMillis();
        System.out.println(N*1000.0/(t2 - t1));
    }
}
