ADTast-experimentalpthread-emulationqualifiedEnum
Last change
on this file since ced5e2a was
678f259,
checked in by Andrew Beach <ajbeach@…>, 3 years ago
|
Some clean-up in the exception benchmark directory. Mostly just shortening names.
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[678f259] | 1 | public class FixupOther { |
---|
[f79ee0d] | 2 | public interface Fixup { |
---|
| 3 | public int op(int fixup); |
---|
| 4 | } |
---|
| 5 | |
---|
| 6 | static void nounwind_fixup(int frames, Fixup raised_rtn, Fixup not_raised_rtn) { |
---|
| 7 | Fixup not_raised = (int fixup) -> frames + 42; // use local scope => lexical link |
---|
| 8 | if (0 < frames) { |
---|
| 9 | nounwind_fixup(frames - 1, raised_rtn, not_raised); |
---|
| 10 | } else { |
---|
| 11 | int fixup = 17; |
---|
| 12 | fixup = raised_rtn.op(fixup); |
---|
| 13 | } |
---|
| 14 | } |
---|
| 15 | |
---|
| 16 | private static long loop(int times, int total_frames) { |
---|
| 17 | Fixup raised = (int fixup) -> total_frames + 42; // use local scope => lexical link |
---|
| 18 | Fixup not_raised = (int fixup) -> total_frames + 42; // use local scope => lexical link |
---|
| 19 | |
---|
| 20 | long startTime = System.nanoTime(); |
---|
| 21 | for (int count = 0 ; count < times ; ++count) { |
---|
| 22 | nounwind_fixup(total_frames, raised, not_raised); |
---|
| 23 | } |
---|
| 24 | long endTime = System.nanoTime(); |
---|
| 25 | return endTime - startTime; |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | public static void main(String[] args) { |
---|
| 29 | int times = 1; |
---|
| 30 | int total_frames = 1; |
---|
| 31 | if (0 < args.length) { |
---|
| 32 | times = Integer.parseInt(args[0]); |
---|
| 33 | } |
---|
| 34 | if (1 < args.length) { |
---|
| 35 | total_frames = Integer.parseInt(args[1]); |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | // Warm-Up: |
---|
| 39 | loop(1000, total_frames); |
---|
| 40 | |
---|
| 41 | long time = loop(times, total_frames); |
---|
| 42 | System.out.format("Run-Time (s): %.1f%n", time / 1_000_000_000.); |
---|
| 43 | } |
---|
| 44 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.