source: doc/theses/andrew_beach_MMath/code/fixup-other.py @ 432bffe

ADTast-experimentalenumforall-pointer-decaypthread-emulationqualifiedEnum
Last change on this file since 432bffe 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: 959 bytes
Line 
1#!/usr/bin/env python3
2
3from time import thread_time_ns
4
5def nounwind_fixup(frames, raised_rtn, not_raised_rtn):
6    not_raised = lambda lfixup : frames + 42            # use local scope => lexical link
7    if 0 < frames:
8        nounwind_fixup(frames - 1, raised_rtn, not_raised)
9    else:
10        fixup = 17;
11        raised_rtn(fixup);
12
13
14def main(argv):
15    times = 1
16    total_frames = 1
17    if 1 < len(argv):
18        times = int(argv[1])
19    if 2 < len(argv):
20        total_frames = int(argv[2])
21
22    raised = lambda lfixup : total_frames + 42          # use local scope => lexical link
23    not_raised = lambda lfixup : total_frames + 42      # use local scope => lexical link
24    start_time = thread_time_ns()
25    for count in range(times):
26        nounwind_fixup(total_frames, raised, not_raised)
27
28    end_time = thread_time_ns()
29    print('Run-Time (s): {:.1f}'.format((end_time - start_time) / 1_000_000_000.))
30
31
32if '__main__' == __name__:
33    import sys
34    main(sys.argv)
Note: See TracBrowser for help on using the repository browser.