[pypy-svn] r39722 - pypy/dist/pypy/rpython/microbench
antocuni at codespeak.net
antocuni at codespeak.net
Fri Mar 2 17:27:46 CET 2007
Author: antocuni
Date: Fri Mar 2 17:27:44 2007
New Revision: 39722
Added:
pypy/dist/pypy/rpython/microbench/dict.py (contents, props changed)
pypy/dist/pypy/rpython/microbench/indirect.py (contents, props changed)
pypy/dist/pypy/rpython/microbench/rdict.py (contents, props changed)
Modified:
pypy/dist/pypy/rpython/microbench/list.py
pypy/dist/pypy/rpython/microbench/microbench.py
Log:
(antocuni, pedronis)
some more microbenchmarks
Added: pypy/dist/pypy/rpython/microbench/dict.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/rpython/microbench/dict.py Fri Mar 2 17:27:44 2007
@@ -0,0 +1,65 @@
+from pypy.rpython.microbench.microbench import MetaBench
+
+class str_dict__set_item:
+ __metaclass__ = MetaBench
+
+ def init():
+ return {}
+ args = ['obj', 'i']
+ def loop(obj, i):
+ obj['foo'] = i
+ obj['bar'] = i
+
+class str_dict__get_item:
+ __metaclass__ = MetaBench
+
+ def init():
+ return {'foo': 0, 'bar': 1}
+ args = ['obj', 'i']
+ def loop(obj, i):
+ return obj['foo'] + obj['bar']
+
+class int_dict__set_item:
+ __metaclass__ = MetaBench
+
+ def init():
+ return {}
+ args = ['obj', 'i']
+ def loop(obj, i):
+ obj[42] = i
+ obj[43] = i
+
+class int_dict__get_item:
+ __metaclass__ = MetaBench
+
+ def init():
+ return {42: 0, 43: 1}
+ args = ['obj', 'i']
+ def loop(obj, i):
+ return obj[42] + obj[43]
+
+
+class Foo:
+ pass
+
+obj1 = Foo()
+obj2 = Foo()
+
+class obj_dict__set_item:
+ __metaclass__ = MetaBench
+
+ def init():
+ return {}
+ args = ['obj', 'i']
+ def loop(obj, i):
+ obj[obj1] = i
+ obj[obj2] = i
+
+class obj_dict__get_item:
+ __metaclass__ = MetaBench
+
+ def init():
+ return {obj1: 0, obj2: 1}
+ args = ['obj', 'i']
+ def loop(obj, i):
+ return obj[obj1] + obj[obj2]
Added: pypy/dist/pypy/rpython/microbench/indirect.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/rpython/microbench/indirect.py Fri Mar 2 17:27:44 2007
@@ -0,0 +1,24 @@
+from pypy.rpython.microbench.microbench import MetaBench
+
+def f1(x):
+ return x
+
+def f2(x):
+ return x+1
+
+def f3(x):
+ return x+2
+
+def f4(x):
+ return x+3
+
+FUNCS = [f1, f2, f3, f4]
+
+class indirect__call:
+ __metaclass__ = MetaBench
+
+ def init():
+ return FUNCS
+ args = ['obj', 'i']
+ def loop(obj, i):
+ return obj[i%4](i)
Modified: pypy/dist/pypy/rpython/microbench/list.py
==============================================================================
--- pypy/dist/pypy/rpython/microbench/list.py (original)
+++ pypy/dist/pypy/rpython/microbench/list.py Fri Mar 2 17:27:44 2007
@@ -1,6 +1,6 @@
from pypy.rpython.microbench.microbench import MetaBench
-class ListAppend:
+class list__append:
__metaclass__ = MetaBench
def init():
return []
@@ -8,7 +8,7 @@
def loop(obj, i):
obj.append(i)
-class ListGetItem:
+class list__get_item:
__metaclass__ = MetaBench
LOOPS = 100000000
def init():
@@ -20,7 +20,7 @@
def loop(obj, i):
return obj[i%1000]
-class ListSetItem:
+class list__set_item:
__metaclass__ = MetaBench
LOOPS = 100000000
def init():
@@ -32,7 +32,7 @@
def loop(obj, i):
obj[i%1000] = i
-class FixedListGetItem:
+class fixed_list__get_item:
__metaclass__ = MetaBench
LOOPS = 100000000
def init():
@@ -41,7 +41,7 @@
def loop(obj, i):
return obj[i%1000]
-class FixedListSetItem:
+class fixed_list__set_item:
__metaclass__ = MetaBench
LOOPS = 100000000
def init():
Modified: pypy/dist/pypy/rpython/microbench/microbench.py
==============================================================================
--- pypy/dist/pypy/rpython/microbench/microbench.py (original)
+++ pypy/dist/pypy/rpython/microbench/microbench.py Fri Mar 2 17:27:44 2007
@@ -90,7 +90,7 @@
c_res = run_benchmark(c_exe)
cli_res = run_benchmark(cli_exe)
- print 'benchmark genc gencli ratio'
+ print 'benchmark genc gencli ratio'
print
for name, _ in benchmarks:
c_time = c_res[name]
@@ -99,7 +99,7 @@
ratio = '%10s' % '---'
else:
ratio = '%10.2f' % (cli_time/c_time)
- print '%-25s %10.2f %10.2f %s' % (name, c_time, cli_time, ratio)
+ print '%-32s %10.2f %10.2f %s' % (name, c_time, cli_time, ratio)
if __name__ == '__main__':
main()
Added: pypy/dist/pypy/rpython/microbench/rdict.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/rpython/microbench/rdict.py Fri Mar 2 17:27:44 2007
@@ -0,0 +1,70 @@
+from pypy.rlib.objectmodel import r_dict
+from pypy.rpython.microbench.microbench import MetaBench
+
+class Obj:
+ def __init__(self, x):
+ self.x = x
+
+def myhash(obj):
+ return obj.x
+
+def mycmp(obj1, obj2):
+ return obj1.x == obj2.x
+
+class Space:
+ def myhash(self, obj):
+ return obj.x
+
+ def mycmp(self, obj1, obj2):
+ return obj1.x == obj2.x
+
+ def _freeze_(self):
+ return True
+
+space = Space()
+obj1 = Obj(1)
+obj2 = Obj(2)
+
+class r_dict__set_item:
+ __metaclass__ = MetaBench
+
+ def init():
+ return r_dict(mycmp, myhash)
+ args = ['obj', 'i']
+ def loop(obj, i):
+ obj[obj1] = i
+ obj[obj2] = i
+
+class r_dict__get_item:
+ __metaclass__ = MetaBench
+
+ def init():
+ res = r_dict(mycmp, myhash)
+ res[obj1] = 42
+ res[obj2] = 43
+ return res
+ args = ['obj', 'i']
+ def loop(obj, i):
+ return obj[obj1] + obj[obj2]
+
+class r_dict__frozen_pbc__set_item:
+ __metaclass__ = MetaBench
+
+ def init():
+ return r_dict(space.mycmp, space.myhash)
+ args = ['obj', 'i']
+ def loop(obj, i):
+ obj[obj1] = i
+ obj[obj2] = i
+
+class r_dict__frozen_pbc__get_item:
+ __metaclass__ = MetaBench
+
+ def init():
+ res = r_dict(space.mycmp, space.myhash)
+ res[obj1] = 42
+ res[obj2] = 43
+ return res
+ args = ['obj', 'i']
+ def loop(obj, i):
+ return obj[obj1] + obj[obj2]
More information about the Pypy-commit
mailing list