bbangert / dozer


WSGI middleware fork of Robert Brewer's Dowser
Clone URL : http://bitbucket.org/bbangert/dozer/ (size: 146.1 KB)
commit 23: 16982f11f336
parent 22: 0b44c20fcd5a
branch: trunk
Adding additional graphics and display fixes
Ben Bangert / bbangert
4 months ago

Changed (Δ769 bytes):

raw changeset »

dozer/media/images/arrows.gif (binary file changed)

dozer/media/images/pip.gif (binary file changed)

dozer/media/profile.css (3 lines added, 3 lines removed)

dozer/profile.py (5 lines added, 1 lines removed)

dozer/templates/show_profile.mako (9 lines added, 3 lines removed)

Up to file-list dozer/media/images/arrows.gif:

Binary file has changed.

Up to file-list dozer/media/images/pip.gif:

Binary file has changed.

Up to file-list dozer/media/profile.css:

@@ -101,9 +101,9 @@ version: 2.5.1
101
101
102
102
#profile .profile_bar li { text-align: center; }
103
103
104
#profile li.step { float: left; padding-left: 4px; background: url(/images/pip.gif) 4px 0 no-repeat; clear: left; }
105
#profile li.with-children { background: url(/images/arrows.gif) 4px 0 no-repeat;}
106
#profile li.tuneup-opened { background: url(/images/arrows.gif) 4px -20px no-repeat; }
104
#profile li.step { float: left; padding-left: 4px; background: url(/_profiler/media/images/pip.gif) 4px 0 no-repeat; clear: left; }
105
#profile li.with-children { background: url(/_profiler/media/images/arrows.gif) 4px 0 no-repeat;}
106
#profile li.opened { background: url(/_profiler/media/images/arrows.gif) 4px -20px no-repeat; }
107
107
108
108
#profile ul { margin: 0; padding: 0; }
109
109
#profile ul span.time { margin-right: 12px; }

Up to file-list dozer/profile.py:

@@ -98,6 +98,7 @@ class Profiler(object):
98
98
        
99
99
        dir_name = self.profile_path or ''
100
100
        cPickle.dump(profile_run, open(os.path.join(dir_name, fname), 'wb'))
101
        del results, tree, profile_run
101
102
        return local['content']
102
103
103
104
@@ -144,10 +145,11 @@ def buildtree(data):
144
145
            node['source_position'] = code.co_firstlineno
145
146
            node['func_name'] = code.co_name
146
147
            node['line_no'] = code.co_firstlineno
147
        node['cost'] = setup_time(entry.totaltime)
148
        node['cost'] = setup_time(entry.inlinetime)
148
149
        node['function'] = label(code)
149
150
        
150
151
        if entry.calls:
152
            start = entry.inlinetime
151
153
            for subentry in entry.calls:
152
154
                subnode = {}
153
155
                subnode['builtin'] = isinstance(subentry.code, str)
@@ -156,6 +158,8 @@ def buildtree(data):
156
158
                subnode['callcount'] = subentry.callcount
157
159
                node.setdefault('calls', []).append(subnode)
158
160
                callregistry.setdefault(subnode['function'], []).append(node['function'])
161
                start += subentry.totaltime
162
            node['cost'] = setup_time(start)
159
163
        else:
160
164
            node['calls'] = []
161
165
        functree[node['function']] = node

Up to file-list dozer/templates/show_profile.mako:

@@ -12,6 +12,12 @@ sys.setrecursionlimit(450)
12
12
    <div id="profile">\
13
13
        <ul>
14
14
        % for node in profile:
15
        <%
16
            if "disable' of '_lsprof.Profiler" in node['function']:
17
                continue
18
            if '<module>' in node['function'] and '<string>:1' in node['function']:
19
                node = profile_data[node['calls'][0]['function']]
20
        %>
15
21
        ${show_node(node, 0, node['cost'])}\
16
22
        % endfor
17
23
        </ul>
@@ -38,7 +44,7 @@ sys.setrecursionlimit(450)
38
44
<ul class="step-info">
39
45
<li class="title"><p><span class="time">${node['cost']}ms</span>
40
46
% if has_children:
41
<a href="#" onclick="$('#children_step_${parent_id}').toggle();$('#step_${parent_id}').toggleClassName('opened');return false;">\
47
<a href="#" onclick="$('#children_step_${parent_id}').toggle();$('#step_${parent_id}').toggleClass('opened');return false;">\
42
48
${node['function']|h}</a>\
43
49
% else:
44
50
${node['function']|h}\
@@ -53,13 +59,13 @@ sys.setrecursionlimit(450)
53
59
<li style="clear: left;">&nbsp;</li>
54
60
</ul>\
55
61
% if has_children:
62
<% depth = depth + 1 %>
56
63
<ul id="children_step_${parent_id}" class="profile_children" style="display:none;">\
57
64
% for called_node in node['calls']:
58
65
<%
59
66
    called = profile_data[called_node['function']]
60
67
    if called_node['builtin']: continue
61
    depth = depth + 1
62
    if depth > 30: continue
68
    if depth > 15: continue
63
69
%>
64
70
${show_node(called, depth, tottime)}\
65
71
% endfor