source: doc/theses/andrew_beach_MMath/code/ThrowOther.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: 1.0 KB
Line 
1// Throw Across Other Handler
2
3class EmptyException extends Exception {}
4
5class NotRaisedException extends Exception {}
6
7public class ThrowOther {
8        static boolean should_throw = false;
9
10        private static void unwind_other(int frames)
11                        throws EmptyException, NotRaisedException {
12                if (0 < frames) {
13                        try {
14                                unwind_other(frames - 1);
15                        } catch (NotRaisedException e) {
16                                // ...
17                        }
18                } else {
19                        if (should_throw) {
20                                throw new NotRaisedException();
21                        }
22                        throw new EmptyException();
23                }
24        }
25
26        public static void main(String[] args) {
27                int times = 1;
28                int total_frames = 1;
29                if (0 < args.length) {
30                        times = Integer.parseInt(args[0]);
31                }
32                if (1 < args.length) {
33                        total_frames = Integer.parseInt(args[1]);
34                }
35
36                long startTime = System.nanoTime();
37                for (int count = 0 ; count < times ; ++count) {
38                        try {
39                                unwind_other(total_frames);
40                        } catch (EmptyException e) {
41                                // ...
42                        } catch (NotRaisedException e) {
43                                // ...
44                        }
45                }
46                long endTime = System.nanoTime();
47                System.out.println("Run-Time (ns) " + (endTime - startTime));
48        }
49}
Note: See TracBrowser for help on using the repository browser.