Tech
Building a Timing Utility That Can't Corrupt Its Own Stats — Even When Your Code Throws
Most ad-hoc timing code in Python looks like this:
start = time . perf_counter ()
result = do_work ()
elapsed = time . perf_counter () - start
stats [ name ]. append ( elapsed )
It works, until do_work() raises. Then the line that records the timing never runs, the exception propagates, and the one call that was probably slowest — the one that failed — is silently missing from your stats. If you're using timing data to find what's expensi...
Read the full discussion on Dev.to
This article was aggregated from Dev.to. Click to join the conversation.
View on Dev.to