ADT
ast-experimental
enum
forall-pointer-decay
jacob/cs343-translation
new-ast-unique-expr
pthread-emulation
qualifiedEnum
Last change
on this file since 37c6f77 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:
1.2 KB
|
Rev | Line | |
---|
[ea593a3] | 1 | // Throw Across Other Handler
|
---|
| 2 |
|
---|
| 3 | class EmptyException extends Exception {}
|
---|
| 4 |
|
---|
| 5 | class NotRaisedException extends Exception {}
|
---|
| 6 |
|
---|
| 7 | public class ThrowOther {
|
---|
| 8 | static boolean should_throw = false;
|
---|
| 9 |
|
---|
| 10 | private static void unwind_other(int frames)
|
---|
| 11 | throws EmptyException, NotRaisedException {
|
---|
| 12 | if (0 < frames) {
|
---|
| 13 | try {
|
---|
| 14 | unwind_other(frames - 1);
|
---|
| 15 | } catch (NotRaisedException e) {
|
---|
| 16 | // ...
|
---|
| 17 | }
|
---|
| 18 | } else {
|
---|
| 19 | if (should_throw) {
|
---|
| 20 | throw new NotRaisedException();
|
---|
| 21 | }
|
---|
| 22 | throw new EmptyException();
|
---|
| 23 | }
|
---|
| 24 | }
|
---|
| 25 |
|
---|
[11d4fa5] | 26 | private static long loop(int times, int total_frames) {
|
---|
[ee23a8d] | 27 | long startTime = System.nanoTime();
|
---|
[ea593a3] | 28 | for (int count = 0 ; count < times ; ++count) {
|
---|
| 29 | try {
|
---|
| 30 | unwind_other(total_frames);
|
---|
| 31 | } catch (EmptyException e) {
|
---|
| 32 | // ...
|
---|
| 33 | } catch (NotRaisedException e) {
|
---|
| 34 | // ...
|
---|
| 35 | }
|
---|
| 36 | }
|
---|
[ee23a8d] | 37 | long endTime = System.nanoTime();
|
---|
[11d4fa5] | 38 | return endTime - startTime;
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | public static void main(String[] args) {
|
---|
| 42 | int times = 1;
|
---|
| 43 | int total_frames = 1;
|
---|
| 44 | if (0 < args.length) {
|
---|
| 45 | times = Integer.parseInt(args[0]);
|
---|
| 46 | }
|
---|
| 47 | if (1 < args.length) {
|
---|
| 48 | total_frames = Integer.parseInt(args[1]);
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | // Warm-Up:
|
---|
| 52 | loop(1000, total_frames);
|
---|
| 53 |
|
---|
| 54 | long time = loop(times, total_frames);
|
---|
| 55 | System.out.println("Run-Time (ns): " + time);
|
---|
[ea593a3] | 56 | }
|
---|
| 57 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.