Calculate the elapsed time.
(self, reset=True)
| 106 | self.started_ = False |
| 107 | |
| 108 | def elapsed(self, reset=True): |
| 109 | """Calculate the elapsed time.""" |
| 110 | started_ = self.started_ |
| 111 | # If the timing in progress, end it first. |
| 112 | if self.started_: |
| 113 | self.stop() |
| 114 | # Get the elapsed time. |
| 115 | elapsed_ = self.elapsed_ |
| 116 | # Reset the elapsed time |
| 117 | if reset: |
| 118 | self.reset() |
| 119 | # If timing was in progress, set it back. |
| 120 | if started_: |
| 121 | self.start() |
| 122 | return elapsed_ |
| 123 | |
| 124 | def __init__(self): |
| 125 | self.timers = {} |