Last change
on this file since 5ca5263 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:
1011 bytes
|
Line | |
---|
1 | public class FixupEmpty { |
---|
2 | public interface Fixup { |
---|
3 | public int op(int fixup); |
---|
4 | } |
---|
5 | |
---|
6 | static void nounwind_fixup(int frames, Fixup raised_rtn) { |
---|
7 | if (0 < frames) { |
---|
8 | nounwind_fixup(frames - 1, raised_rtn); |
---|
9 | } else { |
---|
10 | int fixup = frames; |
---|
11 | fixup = raised_rtn.op(fixup); |
---|
12 | } |
---|
13 | } |
---|
14 | |
---|
15 | private static long loop(int times, int total_frames) { |
---|
16 | Fixup raised = (int fixup) -> total_frames + 42; // use local scope => lexical link |
---|
17 | |
---|
18 | long startTime = System.nanoTime(); |
---|
19 | for (int count = 0 ; count < times ; ++count) { |
---|
20 | nounwind_fixup(total_frames, raised); |
---|
21 | } |
---|
22 | long endTime = System.nanoTime(); |
---|
23 | return endTime - startTime; |
---|
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 | // Warm-Up: |
---|
37 | loop(1000, total_frames); |
---|
38 | |
---|
39 | long time = loop(times, total_frames); |
---|
40 | System.out.format("Run-Time (s): %.1f%n", time / 1_000_000_000.); |
---|
41 | } |
---|
42 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.