Commits

Maciej Fijalkowski committed cdd3773

make stats a bit more useful\

  • Participants
  • Parent commits 4e98c87

Comments (0)

Files changed (2)

pypy/module/pypyjit/interp_resop.py

         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
                                        "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
     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):

pypy/module/pypyjit/test/test_jit_hook.py

         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]