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:
746 bytes
|
Line | |
---|
1 | // Enter and Leave a Try Statement with a Termination Handler |
---|
2 | |
---|
3 | class NotRaisedException extends Exception {} |
---|
4 | |
---|
5 | public class CrossCatch { |
---|
6 | private static boolean shouldThrow = false; |
---|
7 | |
---|
8 | private static long loop(int times) { |
---|
9 | long startTime = System.nanoTime(); |
---|
10 | for (int count = 0 ; count < times ; ++count) { |
---|
11 | try { |
---|
12 | if (shouldThrow) { |
---|
13 | throw new NotRaisedException(); |
---|
14 | } |
---|
15 | } catch (NotRaisedException e) { |
---|
16 | // ... |
---|
17 | } |
---|
18 | } |
---|
19 | long endTime = System.nanoTime(); |
---|
20 | return endTime - startTime; |
---|
21 | } |
---|
22 | |
---|
23 | public static void main(String[] args) { |
---|
24 | int times = 1; |
---|
25 | if (0 < args.length) { |
---|
26 | times = Integer.parseInt(args[0]); |
---|
27 | } |
---|
28 | |
---|
29 | // Warm-Up: |
---|
30 | loop(1000); |
---|
31 | |
---|
32 | long time = loop(times); |
---|
33 | System.out.println("Run-Time (ns): " + time); |
---|
34 | } |
---|
35 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.