source: doc/theses/andrew_beach_MMath/code/CrossCatch.java @ ee23a8d

ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since ee23a8d was ee23a8d, checked in by Andrew Beach <ajbeach@…>, 3 years ago

Added duration information (in nanoseconds) to EHM benchmarks.

  • Property mode set to 100644
File size: 618 bytes
Line 
1// Enter and Leave a Try Statement with a Termination Handler
2
3class NotRaisedException extends Exception {}
4
5public class CrossCatch {
6        public static void main(String[] args) {
7                int times = 1;
8                boolean shouldThrow = false;
9                if (0 < args.length) {
10                        times = Integer.parseInt(args[0]);
11                }
12
13                long startTime = System.nanoTime();
14                for (int count = 0 ; count < times ; ++count) {
15                        try {
16                                if (shouldThrow) {
17                                        throw new NotRaisedException();
18                                }
19                        } catch (NotRaisedException e) {
20                                // ...
21                        }
22                }
23                long endTime = System.nanoTime();
24                System.out.println("Run-Time (ns) " + (endTime - startTime));
25        }
26}
Note: See TracBrowser for help on using the repository browser.