source: doc/theses/andrew_beach_MMath/code/throw-empty.py @ f79ee0d

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

update exception benchmarks

  • Property mode set to 100755
File size: 759 bytes
Line 
1#!/usr/bin/env python3
2
3# Throw Across Empty Function
4
5from time import thread_time_ns
6
7
8class EmptyException(Exception):
9    pass
10
11
12def unwind_empty(frames):
13    if 0 < frames:
14        unwind_empty(frames - 1)
15    else:
16        raise EmptyException()
17
18
19def main(argv):
20    times = 1
21    total_frames = 1
22    if 1 < len(argv):
23        times = int(argv[1])
24    if 2 < len(argv):
25        total_frames = int(argv[2])
26
27    start_time = thread_time_ns()
28    for count in range(times):
29        try:
30            unwind_empty(total_frames)
31        except EmptyException:
32            pass
33
34    end_time = thread_time_ns()
35    print('Run-Time (s) {:.1f}:'.format((end_time - start_time) / 1_000_000_000.))
36
37
38if '__main__' == __name__:
39    import sys
40    main(sys.argv)
Note: See TracBrowser for help on using the repository browser.