Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import datetime
def run_with_no_ex(count: int):
idx = 0
while idx < count:
idx += 1
s = "".upper()
def run_with_ex(count: int):
idx = 0
while idx < count:
idx += 1
s = "".upper()
except Exception as x:
print(f"Error! {x}")
def time(func, count, msg):
t0 =
dt = - t0
print(f'Finished {msg} in {dt.total_seconds()*1000:,.0f}ms')
if __name__ == '__main__':
time(run_with_no_ex, 1_000_000*100, "No exception block")
time(run_with_ex, 1_000_000*100, "Exception block")

This comment has been minimized.

Copy link
Owner Author

@mikeckennedy mikeckennedy commented Sep 29, 2021

Output seems pretty much tied for me:

Finished No exception block in 7,465 ms
Finished Exception block in 7,894 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment