source: doc/theses/andrew_beach_MMath/code/try-catch.py @ 4b75ae9

Last change on this file since 4b75ae9 was b183717, checked in by Andrew Beach <ajbeach@…>, 3 years ago

Update another file in the exception benchmarks as well as some print formatting.

  • 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.