ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationpthread-emulationqualifiedEnum
Last change
on this file since 34fcc13 was
f79ee0d,
checked in by Peter A. Buhr <pabuhr@…>, 3 years ago
|
update exception benchmarks
|
-
Property mode set to
100644
|
File size:
1005 bytes
|
Rev | Line | |
---|
[ea593a3] | 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) { |
---|
[e4da70b] | 9 | try { |
---|
| 10 | unwind_finally(frames - 1); |
---|
| 11 | } finally { |
---|
| 12 | // ... |
---|
| 13 | } |
---|
[ea593a3] | 14 | } else { |
---|
| 15 | throw new EmptyException(); |
---|
| 16 | } |
---|
| 17 | } |
---|
| 18 | |
---|
[11d4fa5] | 19 | private static long loop(int times, int total_frames) { |
---|
| 20 | long startTime = System.nanoTime(); |
---|
| 21 | for (int count = 0 ; count < times ; ++count) { |
---|
| 22 | try { |
---|
| 23 | unwind_finally(total_frames); |
---|
| 24 | } catch (EmptyException e) { |
---|
| 25 | // ... |
---|
| 26 | } |
---|
| 27 | } |
---|
| 28 | long endTime = System.nanoTime(); |
---|
| 29 | return endTime - startTime; |
---|
| 30 | } |
---|
| 31 | |
---|
[ea593a3] | 32 | public static void main(String[] args) { |
---|
| 33 | int times = 1; |
---|
| 34 | int total_frames = 1; |
---|
| 35 | if (0 < args.length) { |
---|
| 36 | times = Integer.parseInt(args[0]); |
---|
| 37 | } |
---|
| 38 | if (1 < args.length) { |
---|
| 39 | total_frames = Integer.parseInt(args[1]); |
---|
| 40 | } |
---|
| 41 | |
---|
[11d4fa5] | 42 | // Warm-Up: |
---|
| 43 | loop(1000, total_frames); |
---|
| 44 | |
---|
| 45 | long time = loop(times, total_frames); |
---|
[f79ee0d] | 46 | System.out.format("Run-Time (s): %.1f%n", time / 1_000_000_000.); |
---|
[ea593a3] | 47 | } |
---|
| 48 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.