Commits

Konstantin Lopuhin committed 6af3ac6

prettier display of loop and op percentages

  • Participants
  • Parent commits ec5611a

Comments (0)

Files changed (4)

File _jitviewer/app.py

     def index(self):
         all = flask.request.args.get('all', None)
         loops = []
-        for index, loop in enumerate(self.storage.loops):
+        for index, loop in enumerate(reversed(sorted(
+                self.storage.loops, 
+                key=lambda l: getattr(l, 'statprof_ratio', 0)))):
             try:
                 start, stop = loop.comment.find('('), loop.comment.rfind(')')
                 name = loop.comment[start + 1:stop]
                 func = DummyFunc()
             func.count = getattr(loop, 'count', '?')
             func.descr = mangle_descr(loop.descr)
-            func.statprof_ratio = getattr(loop, 'statprof_ratio', '?')
-            func.op_capture_ratio = getattr(loop, 'op_capture_ratio', '?')
+            if hasattr(loop, 'statprof_ratio'):
+                func.statprof_percentage = str(loop.statprof_ratio * 100.0)
             loops.append(func)
-        loops.sort(key=lambda l: l.statprof_ratio)
-        loops.reverse()
         if len(loops) > CUTOFF:
             extra_data = "Show all (%d) loops" % len(loops)
         else:
             extra_data = ""
         if not all:
             loops = loops[:CUTOFF]
-
+        jit_percentage = self.storage.jit_ratio * 100.0 \
+                if self.storage.jit_ratio else None
         qt_workaround = ('Qt/4.7.2' in flask.request.user_agent.string)
-        return flask.render_template('index.html', loops=loops,
-                                     jit_ratio=self.storage.jit_ratio,
-                                     filename=self.filename,
-                                     qt_workaround=qt_workaround,
-                                     extra_data=extra_data)
+        return flask.render_template(
+                'index.html', loops=loops,
+                jit_percentage=jit_percentage,
+                filename=self.filename,
+                qt_workaround=qt_workaround,
+                extra_data=extra_data)
 
     def loop(self):
         name = mangle_descr(flask.request.args['name'])
                         op.percentage = int((float(subloop.count) / orig_loop.count)*100)
                     else:
                         op.percentage = '?'
+            if hasattr(op, 'statprof_ratio'):
+                op.statprof_percentage = op.statprof_ratio * 100.0
         loop = FunctionHtml.from_operations(ops, self.storage,
                                             inputargs=orig_loop.inputargs)
         path = flask.request.args.get('path', '').split(',')

File _jitviewer/static/style.css

     font-weight: bold;
 }
 
+.statprof_percentage {
+    color: brown;
+}
+
 /* End of Formatting 
 -----------------------------------------*/
 

File _jitviewer/templates/index.html

   <div>
   <div id="loops">
     <ul>
-      <li>{{jit_ratio}}</li>
+      {% if jit_percentage %}
+      <li>Recorded {{jit_percentage}} %</li>
+      {% endif %}
       {% for item in loops %}
-      <li class="loopitem" id="{{item.descr}}" name="{{item.repr()}}"><span><a href="/" onClick="show_loop('{{item.descr}}'); return false">{{item.repr()}}</a> run {{item.count}} times, {{item.statprof_ratio}}, op capture ratio {{item.op_capture_ratio}}</span></li>
+      <li class="loopitem" id="{{item.descr}}" name="{{item.repr()}}">
+      <span>
+        <a href="/" onClick="show_loop('{{item.descr}}'); return false">{{item.repr()}}</a>
+        run {{item.count}} times{% if item.statprof_percentage %}, ~{{item.statprof_percentage}} % {% endif %}</span></li>
       {% endfor %}
     </ul>
     {% if extra_data %}

File _jitviewer/templates/loop.html

                    {% for op in chunk.operations %}
                       {% if op.name != "debug_merge_point" %}
                         {% if op.bridge %}
-                          <span class="guard single-operation">{{op.html_repr()}} ({{op.statprof_ratio}})</span><a class="bridgelink" href="/" onClick="show_loop('{{op.bridge}}'); return false">&nbsp;show bridge</a>&nbsp; (run {{op.count}} times, ~{{op.percentage}}%)<br/>
+                          <span class="guard single-operation">{{op.html_repr()}} {% if op.statprof_percentage %}<span class="statprof_percentage"> ~{{op.statprof_percentage}} %</span>{% endif %}</span><a class="bridgelink" href="/" onClick="show_loop('{{op.bridge}}'); return false">&nbsp;show bridge</a>&nbsp; (run {{op.count}} times, ~{{op.percentage}}%)<br/>
                           {% if op.asm %}
                             <p class="asm">{{op.asm}}</p>
                           {% endif %}
                         {% else %}
-                          <span class="{{op.html_class()}}">{{op.html_repr()}} ({{op.statprof_ratio}})</span><br/>
+                          <span class="{{op.html_class()}}">{{op.html_repr()}} {% if op.statprof_percentage %}<span class="statprof_percentage"> ~{{op.statprof_percentage}} %</span>{% endif %}</span><br/>
                           {% if op.asm %}
                               <p class="asm">{{op.asm}}</p>
                           {% endif %}