Implement a context manager that measures execution time and sets duration based on exceptions.
Constraints
Example
```python
# Example 1: Normal execution
tc = TimedContext('fast')
with tc:
sum(range(1000))
print(round(tc.duration, 6)) # prints a small non-negative float
# Example 2: Exception case
tc = TimedContext('boom')
try:
with tc:
raise ValueError('oops')
except ValueError:
pass
print(tc.duration) # prints None
```
Recent Submissions
No submissions yet — hit Run Tests to try!
Hints