[pypy-svn] r21502 - pypy/dist/pypy/translator/microbench
ericvrp at codespeak.net
ericvrp at codespeak.net
Thu Dec 22 11:25:49 CET 2005
Author: ericvrp
Date: Thu Dec 22 11:25:49 2005
New Revision: 21502
Modified:
pypy/dist/pypy/translator/microbench/microbench.py
pypy/dist/pypy/translator/microbench/test_count1.py
pypy/dist/pypy/translator/microbench/test_create1.py
Log:
Added some tests. These are some results to show the performance between
python2.4 and python2.3 and between python2.4 and pypy-c.
ericvrp at snake ~/projects/pypy-dist/pypy/translator/microbench $ ./microbench.py python2.4 python2.3 ./pypy
exe: python2.4
exe: python2.3
1.03x slower on test_count1.test_call_method_of_new_style_class()
1.12x slower on test_count1.test_call_method_of_old_style_class()
1.17x slower on test_count1.test_loop()
1.17x slower on test_create1.test_simple_loop_with_new_style_class_creation()
1.18x slower on test_count1.test_call_function()
1.19x slower on test_count1.test_call_nested_function()
1.27x slower on test_create1.test_simple_loop_with_old_style_class_creation()
1.33x slower on test_create1.test_simple_loop()
exe: ./pypy
5.52x slower on test_count1.test_call_nested_function()
5.53x slower on test_count1.test_call_method_of_new_style_class()
5.67x slower on test_count1.test_loop()
5.70x slower on test_count1.test_call_method_of_old_style_class()
6.41x slower on test_count1.test_call_function()
9.33x slower on test_create1.test_simple_loop()
37.27x slower on test_create1.test_simple_loop_with_old_style_class_creation()
46.75x slower on test_create1.test_simple_loop_with_new_style_class_creation()
Modified: pypy/dist/pypy/translator/microbench/microbench.py
==============================================================================
--- pypy/dist/pypy/translator/microbench/microbench.py (original)
+++ pypy/dist/pypy/translator/microbench/microbench.py Thu Dec 22 11:25:49 2005
@@ -1,5 +1,9 @@
#!/usr/bin/python
+"""This script computes the relative performance between python
+implementations on a set of microbenchmarks. The script usally is started
+with "./microbench.py python ./pypy" where pypy is a symlink to you pypy exectable."""
+
import os, time, sys
microbenches = []
@@ -11,7 +15,7 @@
microbenches.append(microbench)
def run():
- MINIMUM_MICROBENCH_TIME = 2.5
+ MINIMUM_MICROBENCH_TIME = 1.0
for microbench in microbenches:
for k in [s for s in globals()[microbench].__dict__ if s.startswith('test_')] :
@@ -26,7 +30,7 @@
print '%s took %.2f seconds' % (testcase, duration / float(n))
if __name__ == '__main__':
- for n, exe in enumerate(sys.argv[1:3]):
+ for n, exe in enumerate(sys.argv[1:]):
print 'exe:', exe
data = [s for s in os.popen(exe + ' microbench.py 2>&1').readlines() if not s.startswith('debug:')]
benchdata = {}
@@ -36,8 +40,13 @@
if n == 0:
benchdata_ref = benchdata
else:
+ result = []
for k, v in benchdata.iteritems():
- print '%s %.2fx slower' % (k, v / benchdata_ref[k])
+ result.append( (v / benchdata_ref[k], k) )
+ result.sort()
+ for r in result:
+ slowdown, testcase = r
+ print '%5.2fx slower on %s' % (slowdown, testcase)
if len(sys.argv) == 1:
run()
Modified: pypy/dist/pypy/translator/microbench/test_count1.py
==============================================================================
--- pypy/dist/pypy/translator/microbench/test_count1.py (original)
+++ pypy/dist/pypy/translator/microbench/test_count1.py Thu Dec 22 11:25:49 2005
@@ -17,3 +17,36 @@
x = plus1(x)
#
+def test_call_nested_function():
+ def plus2(x):
+ return x + 1
+
+ x = 0
+ n = N
+ while x < n:
+ x = plus2(x)
+
+#
+class MyOldStyleClass:
+ def my_method(self, x):
+ return x + 1
+
+class MyNewStyleClass(object):
+ def my_method(self, x):
+ return x + 1
+
+def test_call_method_of_old_style_class():
+ c = MyOldStyleClass()
+ x = 0
+ n = N
+ while x < n:
+ x = c.my_method(x)
+
+def test_call_method_of_new_style_class():
+ c = MyNewStyleClass()
+ x = 0
+ n = N
+ while x < n:
+ x = c.my_method(x)
+
+#
Modified: pypy/dist/pypy/translator/microbench/test_create1.py
==============================================================================
--- pypy/dist/pypy/translator/microbench/test_create1.py (original)
+++ pypy/dist/pypy/translator/microbench/test_create1.py Thu Dec 22 11:25:49 2005
@@ -1,6 +1,9 @@
LOOPS = 1 << 18
-class Foo:
+class OldStyleFoo:
+ pass
+
+class NewStyleFoo(object):
pass
def test_simple_loop():
@@ -8,8 +11,14 @@
while i < LOOPS:
i += 1
-def test_simple_loop_with_class_creation():
+def test_simple_loop_with_old_style_class_creation():
+ i = 0
+ while i < LOOPS:
+ OldStyleFoo()
+ i += 1
+
+def test_simple_loop_with_new_style_class_creation():
i = 0
while i < LOOPS:
- Foo()
+ NewStyleFoo()
i += 1
More information about the Pypy-commit
mailing list