[Python-checkins] r53055 - sandbox/trunk/import_in_py/importbench.py
brett.cannon
python-checkins at python.org
Mon Dec 18 20:41:53 CET 2006
Author: brett.cannon
Date: Mon Dec 18 20:41:53 2006
New Revision: 53055
Added:
sandbox/trunk/import_in_py/importbench.py
Log:
Start a benchmarking script.
Added: sandbox/trunk/import_in_py/importbench.py
==============================================================================
--- (empty file)
+++ sandbox/trunk/import_in_py/importbench.py Mon Dec 18 20:41:53 2006
@@ -0,0 +1,18 @@
+from timeit import Timer
+
+def bench_sys_modules(times=100000, repeat=1):
+ """Benchmark returning a modules from sys.modules."""
+ # We can safely assume timeit has already been imported.
+ timer = Timer("__import__('timeit', {}, {}, [], 0)")
+ return timer.repeat(repeat, times)
+
+
+def main():
+ for name, item in globals().iteritems():
+ if name.startswith('bench_'):
+ timings = item()
+ print "%s: %s" % (item.__name__, timings)
+
+
+if __name__ == '__main__':
+ main()
More information about the Python-checkins
mailing list