[Python-checkins] r46326 - sandbox/trunk/stringbench/stringbench.py

andrew.dalke python-checkins at python.org
Fri May 26 15:55:38 CEST 2006


Author: andrew.dalke
Date: Fri May 26 15:55:38 2006
New Revision: 46326

Modified:
   sandbox/trunk/stringbench/stringbench.py
Log:
benchmark tests for a single split


Modified: sandbox/trunk/stringbench/stringbench.py
==============================================================================
--- sandbox/trunk/stringbench/stringbench.py	(original)
+++ sandbox/trunk/stringbench/stringbench.py	Fri May 26 15:55:38 2006
@@ -339,6 +339,24 @@
     for x in _RANGE_1000:
         s_rsplit()
 
+ at bench('("Here are some words. "*2).split(None, 1)',
+       "split 1 whitespace", 1000)
+def whitespace_split_1(STR):
+    s = STR("Here are some words. "*2)
+    s_split = s.split
+    N = None
+    for x in _RANGE_1000:
+        s_split(N, 1)
+
+ at bench('("Here are some words. "*2).rsplit(None, 1)',
+       "split 1 whitespace", 1000)
+def whitespace_rsplit_1(STR):
+    s = STR("Here are some words. "*2)
+    s_rsplit = s.rsplit
+    N = None
+    for x in _RANGE_1000:
+        s_rsplit(N, 1)
+
 human_text = """\
 Python is a dynamic object-oriented programming language that can be
 used for many kinds of software development. It offers strong support


More information about the Python-checkins mailing list