Timing.py 472 B

1234567891011121314151617181920212223
  1. #
  2. # Get time in platform-dependent way
  3. #
  4. from __future__ import absolute_import
  5. import os
  6. from sys import platform, exit, stderr
  7. if platform == 'mac':
  8. import MacOS
  9. def time():
  10. return MacOS.GetTicks() / 60.0
  11. timekind = "real"
  12. elif hasattr(os, 'times'):
  13. def time():
  14. t = os.times()
  15. return t[0] + t[1]
  16. timekind = "cpu"
  17. else:
  18. stderr.write(
  19. "Don't know how to get time on platform %s\n" % repr(platform))
  20. exit(1)