source: doc/theses/andrew_beach_MMath/code/fixup-empty.py @ 5fdaeab1

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