[Python-checkins] r45918 - sandbox/trunk/sio/bench_cat.py
guido.van.rossum
python-checkins at python.org
Sat May 6 02:29:31 CEST 2006
Author: guido.van.rossum
Date: Sat May 6 02:29:30 2006
New Revision: 45918
Modified:
sandbox/trunk/sio/bench_cat.py
Log:
Add more benchmarks. We now compare str and bytes, for the join and += idioms.
Conclusion: bytes win; and join wins. bytes+= is slower than str.join but not
all that much.
Modified: sandbox/trunk/sio/bench_cat.py
==============================================================================
--- sandbox/trunk/sio/bench_cat.py (original)
+++ sandbox/trunk/sio/bench_cat.py Sat May 6 02:29:30 2006
@@ -13,8 +13,16 @@
timer = timeit.Timer("bbb = bytes()\nfor b in byteses: bbb += b",
"from __main__ import strings, byteses")
- print "byteses %.3f" % min(timer.repeat(3, 10))
+ print "bytes+= %.3f" % min(timer.repeat(3, 10))
+
+ timer = timeit.Timer("bbb = bytes.join(byteses)",
+ "from __main__ import strings, byteses")
+ print "bytes.join %.3f" % min(timer.repeat(3, 10))
+
+ timer = timeit.Timer("sss = ''\nfor s in strings: sss += s",
+ "from __main__ import strings, byteses")
+ print "str+= %.3f" % min(timer.repeat(3, 10))
timer = timeit.Timer("sss = ''.join(strings)",
"from __main__ import strings, byteses")
- print "strings %.3f" % min(timer.repeat(3, 10))
+ print "str.join %.3f" % min(timer.repeat(3, 10))
More information about the Python-checkins
mailing list