ADT
ast-experimental
enum
forall-pointer-decay
jacob/cs343-translation
new-ast-unique-expr
pthread-emulation
qualifiedEnum
Last change
on this file since b7d94ac5 was ee23a8d, checked in by Andrew Beach <ajbeach@…>, 4 years ago |
Added duration information (in nanoseconds) to EHM benchmarks.
|
-
Property mode
set to
100644
|
File size:
896 bytes
|
Line | |
---|
1 | // Conditional Match (or Re-Raise)
|
---|
2 |
|
---|
3 | class EmptyException extends Exception {}
|
---|
4 |
|
---|
5 | public class CondMatch {
|
---|
6 | static boolean should_catch = false;
|
---|
7 |
|
---|
8 | static void throw_exception() throws EmptyException {
|
---|
9 | throw new EmptyException();
|
---|
10 | }
|
---|
11 |
|
---|
12 | static void cond_catch() throws EmptyException {
|
---|
13 | try {
|
---|
14 | throw_exception();
|
---|
15 | } catch (EmptyException exc) {
|
---|
16 | if (!should_catch) {
|
---|
17 | throw exc;
|
---|
18 | }
|
---|
19 | }
|
---|
20 | }
|
---|
21 |
|
---|
22 | public static void main(String[] args) {
|
---|
23 | int times = 1;
|
---|
24 | int total_frames = 1;
|
---|
25 | if (0 < args.length) {
|
---|
26 | times = Integer.parseInt(args[0]);
|
---|
27 | }
|
---|
28 | if (1 < args.length) {
|
---|
29 | total_frames = Integer.parseInt(args[1]);
|
---|
30 | }
|
---|
31 |
|
---|
32 | long startTime = System.nanoTime();
|
---|
33 | for (int count = 0 ; count < times ; ++count) {
|
---|
34 | try {
|
---|
35 | cond_catch();
|
---|
36 | } catch (EmptyException exc) {
|
---|
37 | // ...
|
---|
38 | }
|
---|
39 | }
|
---|
40 | long endTime = System.nanoTime();
|
---|
41 | System.out.println("Run-Time (ns) " + (endTime - startTime));
|
---|
42 | }
|
---|
43 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.