source: doc/theses/andrew_beach_MMath/code/CrossFinally.java @ e4da70b

ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since e4da70b was 11d4fa5, checked in by Andrew Beach <ajbeach@…>, 3 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: 610 bytes
Line 
1// Cross a Try Statement with a Finally Clause
2
3public class CrossFinally {
4        private static boolean shouldThrow = false;
5
6        private static long loop(int times) {
7                long startTime = System.nanoTime();
8                for (int count = 0 ; count < times ; ++count) {
9                        try {
10                                // ...
11                        } finally {
12                                // ...
13                        }
14                }
15                long endTime = System.nanoTime();
16                return endTime - startTime;
17        }
18
19        public static void main(String[] args) {
20                int times = 1;
21                if (0 < args.length) {
22                        times = Integer.parseInt(args[0]);
23                }
24
25                // Warm-Up:
26                loop(1000);
27
28                long time = loop(times);
29                System.out.println("Run-Time (ns): " + time);
30        }
31}
Note: See TracBrowser for help on using the repository browser.