[pypy-svn] r25722 - pypy/dist/pypy/translator/microbench
hpk at codespeak.net
hpk at codespeak.net
Wed Apr 12 14:50:59 CEST 2006
Author: hpk
Date: Wed Apr 12 14:50:59 2006
New Revision: 25722
Added:
pypy/dist/pypy/translator/microbench/test_dict.py
Log:
add a few dictionary (r_dict) related performance tests
comparing a default pypy-c and cpython-2.4.1 gives on my machine:
3.30x slower on test_dict.test_dict_setitem()
3.50x slower on test_dict.test_dict_raw_range()
4.43x slower on test_dict.test_dict_class_dict_getmethod()
5.18x slower on test_dict.test_dict_getitem()
7.71x slower on test_dict.test_dict_instance_setnewattr_instance_dict()
8.00x slower on test_dict.test_dict_instance_getattr_instance_dict()
8.14x slower on test_dict.test_dict_instance_setattr_instance_dict()
Added: pypy/dist/pypy/translator/microbench/test_dict.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/microbench/test_dict.py Wed Apr 12 14:50:59 2006
@@ -0,0 +1,66 @@
+
+iterations = 100000
+def test_dict_setitem():
+ d = {}
+ for x in range(iterations):
+ d[x] = None
+ d[x] = None
+ d[x] = None
+ d[x] = None
+
+d = {}
+for x in range(iterations):
+ d[x] = x
+
+def test_dict_getitem():
+ for x in range(iterations):
+ y = d[x]
+ y = d[x]
+ y = d[x]
+ y = d[x]
+
+def test_dict_raw_range():
+ for x in range(iterations):
+ pass
+
+class A:
+ def __init__(self):
+ self.a = 3
+ self.b = 4
+ def f(self):
+ pass
+ def g(self):
+ pass
+
+
+def test_dict_class_dict_getmethod():
+ a = A()
+ for x in range(iterations):
+ a.f
+ a.f
+ a.f
+ a.f
+
+def test_dict_instance_getattr_instance_dict():
+ a = A()
+ for x in range(iterations):
+ a.a
+ a.b
+ a.a
+ a.b
+
+def test_dict_instance_setattr_instance_dict():
+ a = A()
+ for x in range(iterations):
+ a.a = 3
+ a.b = 4
+ a.a = 3
+ a.b = 4
+
+def test_dict_instance_setnewattr_instance_dict():
+ a = A()
+ for x in range(iterations):
+ a.c = 3
+ a.d = 4
+ a.e = 5
+ a.f = 6
More information about the Pypy-commit
mailing list