Login and get coding
It's time for Context Managers part II. In Bite 20 you used it to roll back a transaction implementing the
In this Bite you will write a context manager using
contextlib.contextmanagerthat measures performance of operations executed in its context:with timeit(): ... measure time in seconds of the the stuff done in this block ...
timeitcontext manager implementing mentioned timing in seconds (duration).
Keep track of performance violations which we define as duration >= 2.2 (
If there are >= 3 (
ALERT_THRESHOLD) violations the same day, print ALERT: suffering performance hit today (
Good luck and keep calm and code in Python!
178 out of 178 users completed this Bite.
Will you be Pythonista #179 to crack this Bite?
Resolution time: ~55 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 7.08 on a 1-10 difficulty scale.
» Up for a challenge? 💪