Last change
on this file since 69ab896 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:
759 bytes
|
Rev | Line | |
---|
[63e3ed8] | 1 | #!/usr/bin/env python3 |
---|
| 2 | |
---|
| 3 | # Throw Across Empty Function |
---|
| 4 | |
---|
| 5 | from time import thread_time_ns |
---|
| 6 | |
---|
| 7 | |
---|
| 8 | class EmptyException(Exception): |
---|
| 9 | pass |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | def unwind_empty(frames): |
---|
| 13 | if 0 < frames: |
---|
| 14 | unwind_empty(frames - 1) |
---|
| 15 | else: |
---|
| 16 | raise EmptyException() |
---|
| 17 | |
---|
| 18 | |
---|
| 19 | def 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() |
---|
[b183717] | 35 | print('Run-Time (s): {:.1f}'.format((end_time - start_time) / 1_000_000_000.)) |
---|
[63e3ed8] | 36 | |
---|
| 37 | |
---|
| 38 | if '__main__' == __name__: |
---|
| 39 | import sys |
---|
| 40 | main(sys.argv) |
---|
Note: See
TracBrowser
for help on using the repository browser.