ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since 70df5f3 was
11d4fa5,
checked in by Andrew Beach <ajbeach@…>, 3 years ago
|
Updated the Java exception benchmarks to provide some warm-up. Does not appear to change results.
|
-
Property mode set to
100644
|
File size:
944 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 | private static long loop(int times, int total_frames) { |
---|
16 | long startTime = System.nanoTime(); |
---|
17 | for (int count = 0 ; count < times ; ++count) { |
---|
18 | try { |
---|
19 | unwind_finally(total_frames); |
---|
20 | } catch (EmptyException e) { |
---|
21 | // ... |
---|
22 | } |
---|
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.println("Run-Time (ns): " + time); |
---|
43 | } |
---|
44 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.