Author: Maciej Fijalkowski <[email protected]>
Branch:
Changeset: r59080:cdd3773b42c4
Date: 2012-11-24 18:03 +0100
http://bitbucket.org/pypy/pypy/changeset/cdd3773b42c4/
Log: make stats a bit more useful\
diff --git a/pypy/module/pypyjit/interp_resop.py
b/pypy/module/pypyjit/interp_resop.py
--- a/pypy/module/pypyjit/interp_resop.py
+++ b/pypy/module/pypyjit/interp_resop.py
@@ -292,10 +292,16 @@
return space.wrap('<JitLoopInfo %s, %d operations, starting at <%s>>' %
(self.jd_name, lgt, code_repr))
+ def descr_get_bridge_no(self, space):
+ if space.is_none(self.w_green_key):
+ return space.wrap(self.bridge_no)
+ raise OperationError(space.w_TypeError, space.wrap("not a bridge"))
+
@unwrap_spec(loopno=int, asmaddr=int, asmlen=int, loop_no=int,
type=str, jd_name=str, bridge_no=int)
def descr_new_jit_loop_info(space, w_subtype, w_greenkey, w_ops, loopno,
- asmaddr, asmlen, loop_no, type, jd_name,
bridge_no):
+ asmaddr, asmlen, loop_no, type, jd_name,
+ bridge_no=-1):
w_info = space.allocate_instance(W_JitLoopInfo, w_subtype)
w_info.w_green_key = w_greenkey
w_info.w_ops = w_ops
@@ -321,6 +327,10 @@
"List of operations in this loop."),
loop_no = interp_attrproperty('loop_no', cls=W_JitLoopInfo, doc=
"Loop cardinal number"),
+ bridge_no = GetSetProperty(W_JitLoopInfo.descr_get_bridge_no,
+ doc="bridge number (if a bridge)"),
+ type = interp_attrproperty('type', cls=W_JitLoopInfo,
+ doc="Loop type"),
__repr__ = interp2app(W_JitLoopInfo.descr_repr),
)
W_JitLoopInfo.acceptable_as_base_class = False
@@ -352,7 +362,9 @@
ll_times = jit_hooks.stats_get_loop_run_times(None)
w_times = space.newdict()
for i in range(len(ll_times)):
- space.setitem(w_times, space.wrap(ll_times[i].number),
+ w_key = space.newtuple([space.wrap(ll_times[i].type),
+ space.wrap(ll_times[i].number)])
+ space.setitem(w_times, w_key,
space.wrap(ll_times[i].counter))
w_counters = space.newdict()
for i, counter_name in enumerate(Counters.counter_names):
diff --git a/pypy/module/pypyjit/test/test_jit_hook.py
b/pypy/module/pypyjit/test/test_jit_hook.py
--- a/pypy/module/pypyjit/test/test_jit_hook.py
+++ b/pypy/module/pypyjit/test/test_jit_hook.py
@@ -118,6 +118,8 @@
assert info.greenkey[1] == 0
assert info.greenkey[2] == False
assert info.loop_no == 0
+ assert info.type == 'loop'
+ raises(TypeError, 'info.bridge_no')
assert len(info.operations) == 4
int_add = info.operations[0]
dmp = info.operations[1]
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit