Author: Hakan Ardo <[email protected]>
Branch: jit-refactor-tests
Changeset: r49810:f47785c0df50
Date: 2011-11-26 12:49 +0100
http://bitbucket.org/pypy/pypy/changeset/f47785c0df50/
Log: convert test
diff --git a/pypy/module/micronumpy/test/test_zjit.py
b/pypy/module/micronumpy/test/test_zjit.py
--- a/pypy/module/micronumpy/test/test_zjit.py
+++ b/pypy/module/micronumpy/test/test_zjit.py
@@ -78,9 +78,10 @@
def test_add(self):
result = self.run("add")
- self.check_loops({'getarrayitem_raw': 2, 'float_add': 1,
- 'setarrayitem_raw': 1, 'int_add': 3,
- 'int_ge': 1, 'guard_false': 1, 'jump': 1})
+ self.check_resops({'setarrayitem_raw': 2, 'getfield_gc': 19,
'guard_class': 11,
+ 'int_add': 6, 'guard_isnull': 1, 'jump': 2,
'int_ge': 2,
+ 'getarrayitem_raw': 4, 'float_add': 2,
'guard_false': 2,
+ 'guard_value': 1})
assert result == 3 + 3
def define_float_add():
@@ -92,9 +93,10 @@
def test_floatadd(self):
result = self.run("float_add")
assert result == 3 + 3
- self.check_loops({"getarrayitem_raw": 1, "float_add": 1,
- "setarrayitem_raw": 1, "int_add": 2,
- "int_ge": 1, "guard_false": 1, "jump": 1})
+ self.check_resops({'setarrayitem_raw': 2, 'getfield_gc': 17,
'guard_class': 11,
+ 'int_add': 4, 'guard_isnull': 1, 'jump': 2,
'int_ge': 2,
+ 'getarrayitem_raw': 2, 'float_add': 2,
'guard_false': 2,
+ 'guard_value': 1})
def define_sum():
return """
@@ -106,9 +108,9 @@
def test_sum(self):
result = self.run("sum")
assert result == 2 * sum(range(30))
- self.check_loops({"getarrayitem_raw": 2, "float_add": 2,
- "int_add": 2,
- "int_ge": 1, "guard_false": 1, "jump": 1})
+ self.check_resops({'guard_class': 10, 'getfield_gc': 17, 'jump': 2,
+ 'getarrayitem_raw': 4, 'guard_value': 2, 'int_add':
4,
+ 'guard_isnull': 1, 'int_ge': 2, 'float_add': 4,
'guard_false': 2})
def define_prod():
return """
@@ -123,9 +125,11 @@
for i in range(30):
expected *= i * 2
assert result == expected
- self.check_loops({"getarrayitem_raw": 2, "float_add": 1,
- "float_mul": 1, "int_add": 2,
- "int_ge": 1, "guard_false": 1, "jump": 1})
+ self.check_resops({'guard_class': 10, 'getfield_gc': 17, 'int_add': 4,
+ 'float_mul': 2, 'guard_isnull': 1, 'jump': 2,
'int_ge': 2,
+ 'getarrayitem_raw': 4, 'float_add': 2,
'guard_false': 2,
+ 'guard_value': 2})
+
def test_max(self):
py.test.skip("broken, investigate")
@@ -149,9 +153,10 @@
min(b)
""")
assert result == -24
- self.check_loops({"getarrayitem_raw": 2, "float_add": 1,
- "float_mul": 1, "int_add": 1,
- "int_lt": 1, "guard_true": 1, "jump": 1})
+ self.check_resops({'guard_class': 10, 'getfield_gc': 15,
'guard_value': 1,
+ 'int_add': 4, 'guard_isnull': 1, 'jump': 2,
'int_ge': 2,
+ 'getarrayitem_raw': 4, 'float_add': 2,
'guard_false': 4,
+ 'float_ne': 2})
def define_any():
return """
@@ -164,10 +169,10 @@
def test_any(self):
result = self.run("any")
assert result == 1
- self.check_loops({"getarrayitem_raw": 2, "float_add": 1,
- "float_ne": 1, "int_add": 2,
- "int_ge": 1, "jump": 1,
- "guard_false": 2})
+ self.check_resops({'guard_class': 10, 'getfield_gc': 15,
'guard_value': 1,
+ 'int_add': 4, 'guard_isnull': 1, 'jump': 2,
'int_ge': 2,
+ 'getarrayitem_raw': 4, 'float_add': 2,
'guard_false': 4,
+ 'float_ne': 2})
def define_already_forced():
return """
@@ -184,9 +189,12 @@
# This is the sum of the ops for both loops, however if you remove the
# optimization then you end up with 2 float_adds, so we can still be
# sure it was optimized correctly.
- self.check_loops({"getarrayitem_raw": 2, "float_mul": 1, "float_add":
1,
- "setarrayitem_raw": 2, "int_add": 4,
- "int_ge": 2, "guard_false": 2, "jump": 2})
+ self.check_resops({'setarrayitem_raw': 4, 'guard_nonnull': 1,
'getfield_gc': 35,
+ 'guard_class': 22, 'int_add': 8, 'float_mul': 2,
+ 'guard_isnull': 2, 'jump': 4, 'int_ge': 4,
+ 'getarrayitem_raw': 4, 'float_add': 2,
'guard_false': 4,
+ 'guard_value': 2})
+
def define_ufunc():
return """
@@ -199,10 +207,11 @@
def test_ufunc(self):
result = self.run("ufunc")
assert result == -6
- self.check_loops({"getarrayitem_raw": 2, "float_add": 1, "float_neg":
1,
- "setarrayitem_raw": 1, "int_add": 3,
- "int_ge": 1, "guard_false": 1, "jump": 1,
- })
+ self.check_resops({'setarrayitem_raw': 2, 'getfield_gc': 24,
'guard_class': 14,
+ 'int_add': 6, 'float_neg': 2, 'guard_isnull': 2,
'jump': 2,
+ 'int_ge': 2, 'getarrayitem_raw': 4, 'float_add': 2,
+ 'guard_false': 2, 'guard_value': 2})
+
def define_specialization():
return """
@@ -255,9 +264,10 @@
def test_multidim(self):
result = self.run('multidim')
assert result == 8
- self.check_loops({'float_add': 1, 'getarrayitem_raw': 2,
- 'guard_false': 1, 'int_add': 3, 'int_ge': 1,
- 'jump': 1, 'setarrayitem_raw': 1})
+ self.check_resops({'setarrayitem_raw': 2, 'getfield_gc': 19,
'guard_class': 11,
+ 'int_add': 6, 'guard_isnull': 1, 'jump': 2,
'int_ge': 2,
+ 'getarrayitem_raw': 4, 'float_add': 2,
'guard_false': 2,
+ 'guard_value': 1})
# int_add might be 1 here if we try slightly harder with
# reusing indexes or some optimization
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit