test.py 508 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env python
  2. import sys
  3. from timeit import Timer
  4. from stations import locator
  5. call = sys.argv[1]
  6. print repr(call)
  7. D = {}
  8. for line in file('stations.dat'):
  9. c, l = [x.strip() for x in line.split(',')]
  10. D[c] = l
  11. def test1(c):
  12. return D[c]
  13. print repr(test1(call))
  14. t = Timer("test1(%r)" % call, "from __main__ import test1")
  15. print t.timeit()
  16. # -----
  17. def test2(c):
  18. return locator(c)
  19. print repr(test2(call))
  20. t = Timer("test2(%r)" % call, "from __main__ import test2")
  21. print t.timeit()