[pypy-svn] r39799 - pypy/dist/pypy/translator/microbench

guido at codespeak.net guido at codespeak.net
Sat Mar 3 14:21:35 CET 2007


Author: guido
Date: Sat Mar  3 14:21:33 2007
New Revision: 39799

Added:
   pypy/dist/pypy/translator/microbench/test_formatting.py
Log:
Microbenchmark for string formatting.


Added: pypy/dist/pypy/translator/microbench/test_formatting.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/microbench/test_formatting.py	Sat Mar  3 14:21:33 2007
@@ -0,0 +1,28 @@
+iterations = 100000
+
+def test_simple_formatting():
+    i = 0
+    while i < iterations:
+        '%s - %s - %s' % ('foo', 'bar', 'baz')
+        i += 1
+
+def test_dict_formatting():
+    i = 0
+    d = {'foo': 'bar', 'baz': 'qux'}
+    while i < iterations:
+        '%(foo)s - %(baz)s' % d
+        i += 1
+
+def test_number_formatting():
+    i = 0
+    while i < iterations:
+        '%04d %g %2f' % (10, 10.1234, 10.1234)
+        i += 1
+
+def test_repr_formatting():
+    i = 0
+    d = {'foo': 'bar', 'baz': 'qux'}
+    while i < iterations:
+        '%r' % (d,)
+        i += 1
+



More information about the Pypy-commit mailing list