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:
785 bytes
|
Line | |
---|
1 | // Throw Across Finally |
---|
2 | |
---|
3 | class EmptyException extends Exception {} |
---|
4 | |
---|
5 | public class ThrowFinally { |
---|
6 | private static void unwind_finally(int frames) |
---|
7 | throws EmptyException { |
---|
8 | if (0 < frames) { |
---|
9 | unwind_finally(frames - 1); |
---|
10 | } else { |
---|
11 | throw new EmptyException(); |
---|
12 | } |
---|
13 | } |
---|
14 | |
---|
15 | public static void main(String[] args) { |
---|
16 | int times = 1; |
---|
17 | int total_frames = 1; |
---|
18 | if (0 < args.length) { |
---|
19 | times = Integer.parseInt(args[0]); |
---|
20 | } |
---|
21 | if (1 < args.length) { |
---|
22 | total_frames = Integer.parseInt(args[1]); |
---|
23 | } |
---|
24 | |
---|
25 | long startTime = System.nanoTime(); |
---|
26 | for (int count = 0 ; count < times ; ++count) { |
---|
27 | try { |
---|
28 | unwind_finally(total_frames); |
---|
29 | } catch (EmptyException e) { |
---|
30 | // ... |
---|
31 | } |
---|
32 | } |
---|
33 | long endTime = System.nanoTime(); |
---|
34 | System.out.println("Run-Time (ns) " + (endTime - startTime)); |
---|
35 | } |
---|
36 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.