Increment the counter and return the current value with jitter.
(self)
| 57 | self._max = max_counter |
| 58 | |
| 59 | def counter(self) -> int | float: |
| 60 | """Increment the counter and return the current value with jitter.""" |
| 61 | max_jitter = self._base / 16.0 |
| 62 | value = self._base + random.random() * max_jitter - max_jitter / 2 # noqa: S311 |
| 63 | self._base = min(self._base * 2, self._max) |
| 64 | return value |
| 65 | |
| 66 | def reset(self) -> None: |
| 67 | """Reset the counter to 1.""" |
no outgoing calls