ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since acb38ce9 was
8ee4475,
checked in by Andrew Beach <ajbeach@…>, 3 years ago
|
Conditional matching benchmarks renamed based on type of catch used (catch=recover).
|
-
Property mode set to
100644
|
File size:
877 bytes
|
Rev | Line | |
---|
[ea593a3] | 1 | // Conditional Match (or Re-Raise) |
---|
| 2 | |
---|
| 3 | class EmptyException extends Exception {} |
---|
| 4 | |
---|
[8ee4475] | 5 | public class CondCatch { |
---|
[ea593a3] | 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 | if (0 < args.length) { |
---|
| 25 | times = Integer.parseInt(args[0]); |
---|
| 26 | } |
---|
| 27 | if (1 < args.length) { |
---|
[11ad42f] | 28 | should_catch = 0 != Integer.parseInt(args[1]); |
---|
[ea593a3] | 29 | } |
---|
| 30 | |
---|
[ee23a8d] | 31 | long startTime = System.nanoTime(); |
---|
[ea593a3] | 32 | for (int count = 0 ; count < times ; ++count) { |
---|
| 33 | try { |
---|
| 34 | cond_catch(); |
---|
| 35 | } catch (EmptyException exc) { |
---|
| 36 | // ... |
---|
| 37 | } |
---|
| 38 | } |
---|
[ee23a8d] | 39 | long endTime = System.nanoTime(); |
---|
| 40 | System.out.println("Run-Time (ns) " + (endTime - startTime)); |
---|
[ea593a3] | 41 | } |
---|
| 42 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.