Calculate the elapsed time.
(self, reset=True)
| 142 | self.started_ = False |
| 143 | |
| 144 | def elapsed(self, reset=True): |
| 145 | """Calculate the elapsed time.""" |
| 146 | started_ = self.started_ |
| 147 | # If the timing in progress, end it first. |
| 148 | if self.started_: |
| 149 | self.stop() |
| 150 | # Get the elapsed time. |
| 151 | elapsed_ = self.elapsed_ |
| 152 | # Reset the elapsed time |
| 153 | if reset: |
| 154 | self.reset() |
| 155 | # If timing was in progress, set it back. |
| 156 | if started_: |
| 157 | self.start() |
| 158 | return elapsed_ |
| 159 | |
| 160 | def __init__(self): |
| 161 | self.timers = {} |