Calculate the elapsed time.
(self, reset=True)
| 96 | self.started_ = False |
| 97 | |
| 98 | def elapsed(self, reset=True): |
| 99 | """Calculate the elapsed time.""" |
| 100 | started_ = self.started_ |
| 101 | # If the timing in progress, end it first. |
| 102 | if self.started_: |
| 103 | self.stop() |
| 104 | # Get the elapsed time. |
| 105 | elapsed_ = self.elapsed_ |
| 106 | # Reset the elapsed time |
| 107 | if reset: |
| 108 | self.reset() |
| 109 | # If timing was in progress, set it back. |
| 110 | if started_: |
| 111 | self.start() |
| 112 | return elapsed_ |
| 113 | |
| 114 | def __init__(self): |
| 115 | self.timers = {} |