accurate_time.py 385 B

123456789101112131415161718
  1. import time as t
  2. import os
  3. global start_time
  4. def set_start_time():
  5. global start_time
  6. if os.name == 'posix':
  7. start_time = t.time()
  8. elif os.name == 'nt':
  9. start_time = t.clock()
  10. if os.name == 'posix':
  11. def time():
  12. return int((t.time() - start_time) * 1000)
  13. elif os.name == 'nt':
  14. def time():
  15. return int((t.clock() - start_time) * 1000)