Terminate the current phase.
(self, tokens: int, now: Optional[float] = None)
| 34 | self.current = None |
| 35 | |
| 36 | def end_phase(self, tokens: int, now: Optional[float] = None): |
| 37 | """Terminate the current phase.""" |
| 38 | if self.current is None: |
| 39 | return |
| 40 | if now is None: |
| 41 | now = time.time() |
| 42 | cname, ctokens, ctime = self.current |
| 43 | stats = PhaseStats( |
| 44 | name=cname, |
| 45 | tokens=tokens - ctokens, |
| 46 | time=now - ctime, |
| 47 | ) |
| 48 | self.phases.append(stats) |
| 49 | |
| 50 | def phase(self, name: str, tokens: int = 0): |
| 51 | """ |
no test coverage detected