Changeset 1a6a6f2 for doc/theses/andrew_beach_MMath/code/CondCatch.java
- Timestamp:
- Aug 19, 2021, 4:04:43 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, pthread-emulation, qualifiedEnum
- Children:
- d8f8d08
- Parents:
- ed4d7c1 (diff), 315e5e3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/andrew_beach_MMath/code/CondCatch.java
red4d7c1 r1a6a6f2 6 6 static boolean should_catch = false; 7 7 8 static void throw_exception() throws EmptyException {9 throw new EmptyException();10 }11 12 static void cond_catch() throws EmptyException {13 try {14 throw_exception();15 } catch (EmptyException exc) {16 if (!should_catch) {17 throw exc;18 }19 }20 }21 22 8 private static long loop(int times) { 23 9 long startTime = System.nanoTime(); 24 10 for (int count = 0 ; count < times ; ++count) { 25 11 try { 26 cond_catch(); 12 try { 13 throw new EmptyException(); 14 } catch (EmptyException exc) { 15 if (!should_catch) { 16 throw exc; 17 } 18 } 27 19 } catch (EmptyException exc) { 28 20 // ... … … 46 38 47 39 long time = loop(times); 48 System.out. println("Run-Time (ns): " + time);40 System.out.format("Run-Time (s): %.1f%n", time / 1_000_000_000.); 49 41 } 50 42 }
Note: See TracChangeset
for help on using the changeset viewer.