[Python-checkins] r46228 - sandbox/trunk/stringbench/stringbench.py
andrew.dalke
python-checkins at python.org
Thu May 25 19:43:11 CEST 2006
Author: andrew.dalke
Date: Thu May 25 19:43:10 2006
New Revision: 46228
Modified:
sandbox/trunk/stringbench/stringbench.py
Log:
Added benchmarks for lower() and upper() methods.
Modified: sandbox/trunk/stringbench/stringbench.py
==============================================================================
--- sandbox/trunk/stringbench/stringbench.py (original)
+++ sandbox/trunk/stringbench/stringbench.py Thu May 25 19:43:10 2006
@@ -767,6 +767,43 @@
for x in _RANGE_1000:
s % d
+
+#### Upper- and lower- case conversion
+
+ at bench('"Where in the world is Carmen San Deigo?".lower()',
+ "case conversion -- rare", 1000)
+def lower_conversion_rare(STR):
+ s = STR("Where in the world is Carmen San Deigo?")
+ s_lower = s.lower
+ for x in _RANGE_1000:
+ s_lower()
+
+ at bench('"WHERE IN THE WORLD IS CARMEN SAN DEIGO?".lower()',
+ "case conversion -- dense", 1000)
+def lower_conversion_dense(STR):
+ s = STR("WHERE IN THE WORLD IS CARMEN SAN DEIGO?")
+ s_lower = s.lower
+ for x in _RANGE_1000:
+ s_lower()
+
+
+ at bench('"wHERE IN THE WORLD IS cARMEN sAN dEIGO?".upper()',
+ "case conversion -- rare", 1000)
+def upper_conversion_rare(STR):
+ s = STR("Where in the world is Carmen San Deigo?")
+ s_upper = s.upper
+ for x in _RANGE_1000:
+ s_upper()
+
+ at bench('"where in the world is carmen san deigo?".upper()',
+ "case conversion -- dense", 1000)
+def upper_conversion_dense(STR):
+ s = STR("where in the world is carmen san deigo?")
+ s_upper = s.upper
+ for x in _RANGE_1000:
+ s_upper()
+
+
# end of benchmarks
#################
More information about the Python-checkins
mailing list