source: doc/theses/andrew_beach_MMath/code/throw_empty.py @ e4da70b

ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since e4da70b was 63e3ed8, checked in by Andrew Beach <ajbeach@…>, 3 years ago

Added Python versions of the exception benchmarks.

  • Property mode set to 100755
File size: 727 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 (ns):', end_time - start_time)
36
37
38if '__main__' == __name__:
39    import sys
40    main(sys.argv)
Note: See TracBrowser for help on using the repository browser.