ADT
ast-experimental
enum
forall-pointer-decay
jacob/cs343-translation
new-ast-unique-expr
pthread-emulation
qualifiedEnum
Last change
on this file since 47e413b was 11d4fa5, checked in by Andrew Beach <ajbeach@…>, 4 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
|
Rev | Line | |
---|
[ea593a3] | 1 | // Enter and Leave a Try Statement with a Termination Handler
|
---|
| 2 |
|
---|
| 3 | class NotRaisedException extends Exception {}
|
---|
| 4 |
|
---|
| 5 | public class CrossCatch {
|
---|
[11d4fa5] | 6 | private static boolean shouldThrow = false;
|
---|
[ea593a3] | 7 |
|
---|
[11d4fa5] | 8 | private static long loop(int times) {
|
---|
[ee23a8d] | 9 | long startTime = System.nanoTime();
|
---|
[ea593a3] | 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 | }
|
---|
[ee23a8d] | 19 | long endTime = System.nanoTime();
|
---|
[11d4fa5] | 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);
|
---|
[ea593a3] | 34 | }
|
---|
| 35 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.