1. Jason Pellerin
  2. dozer

Commits

Marius Gedminas  committed 19a14f7

Show cost in profile list; show error type as well as message.

  • Participants
  • Parent commits 0ee3df2
  • Branches trunk

Comments (0)

Files changed (2)

File dozer/profile.py

View file
  • Ignore whitespace
                 try:
                     data = cPickle.load(open(path, 'rb'))
                 except Exception, e:
-                    errors.append((modified, str(e), profile_file[:-4]))
+                    errors.append((modified, '%s: %s' % (e.__class__.__name__, e), profile_file[:-4]))
                 else:
                     environ = data['environ']
-                    profiles.append((modified, environ, profile_file[:-4]))
+                    top = [x for x in data['profile'].values() if not x.get('callers')]
+                    if top:
+                        total_cost = max(x['cost'] for x in top)
+                    else:
+                        total_cost = 0
+                    profiles.append((modified, environ, total_cost, profile_file[:-4]))
 
         profiles.sort(reverse=True)
         errors.sort(reverse=True)

File dozer/templates/list_profiles.mako

View file
  • Ignore whitespace
 <table id="profile-list">
     <tr>
         <th>URL</th>
+        <th>Cost</th>
         <th>Time</th>
         <th>Profile ID</th>
         <th></th>
     </tr>
-    % for created_time, environ, profile_id in profiles:
+    % for created_time, environ, total_cost, profile_id in profiles:
     <tr pid="${profile_id}">
         <td>${environ['SCRIPT_NAME'] + environ['PATH_INFO'] + environ['QUERY_STRING']|h}</td>
+        <td>${total_cost} ms</td>
         <td>${'%i' % int(now-created_time)} seconds ago</td>
         <td><a href="/_profiler/show/${profile_id}">${profile_id}</a></td>
         <td><a href="/_profiler/delete/${profile_id}" class="delete">delete</a></td>
     % endfor
     % if errors:
     <tr>
-        <th>Error</th>
+        <th colspan="2">Error</th>
         <th>Time</th>
         <th>Profile ID</th>
         <th></th>
     </tr>
     % for created_time, error, profile_id in errors:
     <tr pid="${profile_id}">
-        <td>${error|h}</td>
+        <td colspan="2">${error|h}</td>
         <td>${'%i' % int(now-created_time)} seconds ago</td>
         <td>${profile_id}</td>
         <td><a href="/_profiler/delete/${profile_id}" class="delete">delete</a></td>