source: doc/theses/andrew_beach_MMath/code/try-catch.py @ 2a3f0d9

ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationpthread-emulationqualifiedEnum
Last change on this file since 2a3f0d9 was f79ee0d, checked in by Peter A. Buhr <pabuhr@…>, 3 years ago

update exception benchmarks

  • Property mode set to 100755
File size: 567 bytes
Line 
1#!/usr/bin/env python3
2
3# Cross a Try Statement with a Termination Handler
4
5from time import thread_time_ns
6
7
8class NotRaisedException(Exception):
9    pass
10
11
12def main(argv):
13    times = 1;
14    if 1 < len(argv):
15        times = int(argv[1])
16
17    start_time = thread_time_ns()
18    for count in range(times):
19        try:
20            pass
21        except NotRaisedException:
22            pass
23
24    end_time = thread_time_ns()
25    print('Run-Time (s) {:.1f}:'.format((end_time - start_time) / 1_000_000_000.))
26
27
28if '__main__' == __name__:
29    import sys
30    main(sys.argv)
Note: See TracBrowser for help on using the repository browser.