ADT
ast-experimental
enum
forall-pointer-decay
jacob/cs343-translation
new-ast-unique-expr
pthread-emulation
qualifiedEnum
Last change
on this file since 8f1a99e 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:
618 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 | public static void main(String[] args) {
|
---|
7 | int times = 1;
|
---|
8 | boolean shouldThrow = false;
|
---|
9 | if (0 < args.length) {
|
---|
10 | times = Integer.parseInt(args[0]);
|
---|
11 | }
|
---|
12 |
|
---|
13 | long startTime = System.nanoTime();
|
---|
14 | for (int count = 0 ; count < times ; ++count) {
|
---|
15 | try {
|
---|
16 | if (shouldThrow) {
|
---|
17 | throw new NotRaisedException();
|
---|
18 | }
|
---|
19 | } catch (NotRaisedException e) {
|
---|
20 | // ...
|
---|
21 | }
|
---|
22 | }
|
---|
23 | long endTime = System.nanoTime();
|
---|
24 | System.out.println("Run-Time (ns) " + (endTime - startTime));
|
---|
25 | }
|
---|
26 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.