timestamp.py 410 B

12345678910111213141516171819202122
  1. # Copyright (c) Microsoft Corporation. All rights reserved.
  2. # Licensed under the MIT License. See LICENSE in the project root
  3. # for license information.
  4. """Provides monotonic timestamps with a resetable zero.
  5. """
  6. import time
  7. __all__ = ["current", "reset"]
  8. def current():
  9. return time.monotonic() - timestamp_zero
  10. def reset():
  11. global timestamp_zero
  12. timestamp_zero = time.monotonic()
  13. reset()