summaryrefslogtreecommitdiff
path: root/components/rtgui/utils/perfect_hash/example-PyModule/test.py
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2013-01-31 18:59:34 -0800
committerBernard Xiong <[email protected]>2013-01-31 18:59:34 -0800
commit9400f237b29b9dc1ed3539cf7c0052a4d0456c9b (patch)
tree89fd3a989b4d88fc72b39eaad6567de3a3d23874 /components/rtgui/utils/perfect_hash/example-PyModule/test.py
parent4f02e67bef7eacee5102d7730356663d9c889e15 (diff)
parentf06c70feed0941b5bceedcecf89e9aa22034aca8 (diff)
Merge pull request #22 from grissiom/rtgui-0.6
sync with rtgui-0.6
Diffstat (limited to 'components/rtgui/utils/perfect_hash/example-PyModule/test.py')
-rw-r--r--components/rtgui/utils/perfect_hash/example-PyModule/test.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/components/rtgui/utils/perfect_hash/example-PyModule/test.py b/components/rtgui/utils/perfect_hash/example-PyModule/test.py
new file mode 100644
index 0000000000..02c06b6926
--- /dev/null
+++ b/components/rtgui/utils/perfect_hash/example-PyModule/test.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+import sys
+from timeit import Timer
+from stations import locator
+
+call = sys.argv[1]
+print repr(call)
+D = {}
+
+for line in file('stations.dat'):
+ c, l = [x.strip() for x in line.split(',')]
+ D[c] = l
+
+def test1(c):
+ return D[c]
+
+print repr(test1(call))
+t = Timer("test1(%r)" % call, "from __main__ import test1")
+print t.timeit()
+
+# -----
+
+def test2(c):
+ return locator(c)
+
+print repr(test2(call))
+t = Timer("test2(%r)" % call, "from __main__ import test2")
+print t.timeit()