ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since b0b89a8 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:
843 bytes
|
Rev | Line | |
---|
[63e3ed8] | 1 | #!/usr/bin/env python3 |
---|
| 2 | |
---|
| 3 | # Throw Across Other Handler |
---|
| 4 | |
---|
| 5 | from time import thread_time_ns |
---|
| 6 | |
---|
| 7 | |
---|
| 8 | class EmptyException(Exception): |
---|
| 9 | pass |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | class NotRaisedException(Exception): |
---|
| 13 | pass |
---|
| 14 | |
---|
| 15 | |
---|
| 16 | def unwind_other(frames): |
---|
| 17 | if 0 < frames: |
---|
| 18 | try: |
---|
| 19 | unwind_other(frames - 1) |
---|
| 20 | except NotRaisedException: |
---|
| 21 | pass |
---|
| 22 | else: |
---|
| 23 | raise EmptyException() |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | def main(argv): |
---|
| 27 | times = 1 |
---|
| 28 | total_frames = 1 |
---|
| 29 | if 1 < len(argv): |
---|
| 30 | times = int(argv[1]) |
---|
| 31 | if 2 < len(argv): |
---|
| 32 | total_frames = int(argv[2]) |
---|
| 33 | |
---|
| 34 | start_time = thread_time_ns() |
---|
| 35 | for count in range(times): |
---|
| 36 | try: |
---|
| 37 | unwind_other(total_frames) |
---|
| 38 | except EmptyException: |
---|
| 39 | pass |
---|
| 40 | |
---|
| 41 | end_time = thread_time_ns() |
---|
| 42 | print('Run-Time (ns):', end_time - start_time) |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | if '__main__' == __name__: |
---|
| 46 | import sys |
---|
| 47 | main(sys.argv) |
---|
Note: See
TracBrowser
for help on using the repository browser.