ADT
ast-experimental
enum
forall-pointer-decay
jacob/cs343-translation
pthread-emulation
qualifiedEnum
Last change
on this file since d00d581 was e4da70b, checked in by Andrew Beach <ajbeach@…>, 4 years ago |
Added another helper script for exception benchmarks and fixed up the Java benchmarks.
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Line | |
---|
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 if (should_throw) {
|
---|
19 | throw new NotRaisedException();
|
---|
20 | } else {
|
---|
21 | throw new EmptyException();
|
---|
22 | }
|
---|
23 | }
|
---|
24 |
|
---|
25 | private static long loop(int times, int total_frames) {
|
---|
26 | long startTime = System.nanoTime();
|
---|
27 | for (int count = 0 ; count < times ; ++count) {
|
---|
28 | try {
|
---|
29 | unwind_other(total_frames);
|
---|
30 | } catch (EmptyException e) {
|
---|
31 | // ...
|
---|
32 | } catch (NotRaisedException e) {
|
---|
33 | // ...
|
---|
34 | }
|
---|
35 | }
|
---|
36 | long endTime = System.nanoTime();
|
---|
37 | return endTime - startTime;
|
---|
38 | }
|
---|
39 |
|
---|
40 | public static void main(String[] args) {
|
---|
41 | int times = 1;
|
---|
42 | int total_frames = 1;
|
---|
43 | if (0 < args.length) {
|
---|
44 | times = Integer.parseInt(args[0]);
|
---|
45 | }
|
---|
46 | if (1 < args.length) {
|
---|
47 | total_frames = Integer.parseInt(args[1]);
|
---|
48 | }
|
---|
49 |
|
---|
50 | // Warm-Up:
|
---|
51 | loop(1000, total_frames);
|
---|
52 |
|
---|
53 | long time = loop(times, total_frames);
|
---|
54 | System.out.println("Run-Time (ns): " + time);
|
---|
55 | }
|
---|
56 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.