PageRenderTime 52ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/pypy/rlib/test/test_rtimer.py

https://bitbucket.org/varialus/jyjy
Python | 28 lines | 21 code | 5 blank | 2 comment | 1 complexity | e1a336576f204496cd80f269e5b60a32 MD5 | raw file
  1. import time
  2. from pypy.rlib.rtimer import read_timestamp
  3. from pypy.rpython.test.test_llinterp import interpret
  4. from pypy.translator.c.test.test_genc import compile
  5. def timer():
  6. t1 = read_timestamp()
  7. start = time.time()
  8. while time.time() - start < 0.1:
  9. # busy wait
  10. pass
  11. t2 = read_timestamp()
  12. return t2 - t1
  13. def test_timer():
  14. diff = timer()
  15. # We're counting ticks, verify they look correct
  16. assert diff > 1000
  17. def test_annotation():
  18. diff = interpret(timer, [])
  19. assert diff > 1000
  20. def test_compile_c():
  21. function = compile(timer, [])
  22. diff = function()
  23. assert diff > 1000