Commits

Marius Gedminas  committed 6b68844

Show bars indicating request cost.

  • Participants
  • Parent commits 4ec47fa

Comments (0)

Files changed (3)

File dozer/media/css/profile.css

 #profile ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul .title { width: 432px; }
 #profile ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul .title { width: 428px; }
 #profile ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul .title { width: 424px; }
+#profile ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul .title { width: 420px; }
+#profile ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul .title { width: 416px; }
+#profile ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul .title { width: 412px; }
+#profile ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul .title { width: 408px; }
+#profile ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul .title { width: 404px; }
+#profile ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul .title { width: 400px; }
 
 
 #profile-flash { display: none; text-align: left; font-size: 12px; padding: 5px; color: #000; border-bottom: 1px #000 solid; }
 #profile-list td { text-align: left; }
 #profile-list tr:hover { background: #444; }
 #profile-list tr:hover td { background: #444 !important; }
+#profile-list div.box { position: relative; }
+#profile-list span.bar { background: #774b00; position: absolute; right: -5px; top: 0; z-index: -1; }

File dozer/profile.py

         dir_name = self.profile_path
         profiles = []
         errors = []
+        max_cost = 0
         for profile_file in os.listdir(dir_name):
             if profile_file.endswith('.pkl'):
                 path = os.path.join(self.profile_path, profile_file)
                     environ = data['environ']
                     top = [x for x in data['profile'].values() if not x.get('callers')]
                     if top:
-                        total_cost = max(x['cost'] for x in top)
+                        total_cost = max(float(x['cost']) for x in top)
                     else:
                         total_cost = 0
+                    max_cost = max(max_cost, total_cost)
                     profiles.append((modified, environ, total_cost, profile_file[:-4]))
 
         profiles.sort(reverse=True)
             earliest = None
         res.body = self.render('/list_profiles.mako', profiles=profiles,
                                errors=errors, now=time.time(),
-                               earliest=earliest)
+                               earliest=earliest, max_cost=max_cost)
         return res
     showall.exposed = True
 

File dozer/templates/list_profiles.mako

     </tr>
     % for created_time, environ, total_cost, profile_id in profiles:
     <%
-        w = (now-created_time) / (now-earliest)  # 0 .. 1
-        w = 1 - w
+        width = round(400.0 * total_cost / max_cost)
+        w = 1 - (now-created_time) / (now-earliest)  # 0 .. 1
         w = round(w * 255)
         bg = '#%02x%02x%02x' % (w, w, w)
         if w > 128:
     %>
     <tr pid="${profile_id}">
         <td class="url">${environ['SCRIPT_NAME'] + environ['PATH_INFO'] + environ['QUERY_STRING']|h}</td>
-        <td class="cost">${total_cost} ms</td>
-        <td class="time" style="background: ${bg}; color: ${fg};">${'%i' % int(now-created_time)} seconds ago</td>
+        <td class="cost">\
+<div class="box">\
+${total_cost}&nbsp;ms\
+<span class="bar" style="width: ${width}px">&nbsp;</span>\
+</div>\
+</td>
+        <td class="time" style="background: ${bg}; color: ${fg};">${'%i' % int(now-created_time)}&nbsp;seconds&nbsp;ago</td>
         <td class="pid"><a href="/_profiler/show/${profile_id}">${profile_id}</a></td>
         <td class="delete"><a href="/_profiler/delete/${profile_id}" class="delete">delete</a></td>
     </tr>