summaryrefslogtreecommitdiffstats
path: root/venv/lib/python3.9/site-packages/pympler/templates/tracker.tpl
blob: 8533e9ebd969060822c37ff13e2db066cffaf101 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
%include('header', category='Tracker', title='Tracked objects')

%from pympler.util.stringutils import pp, pp_timestamp
%from json import dumps

<h1>Tracked objects</h1>

%if snapshots:

    <h2>Memory distribution over time</h2>

    <div id="memory_chart_flot" style="width:100%; height: 400px"></div>

    <script type="text/javascript" src="/static/jquery.flot.min.js"></script>
    <script type="text/javascript" src="/static/jquery.flot.stack.min.js"></script>
    <script type="text/javascript" src="/static/jquery.flot.tooltip.min.js"></script>
    <script type="text/javascript">
        function format_size(value) {
            var val = Math.round(value / (1000*1000));
            return val.toLocaleString() + ' MB';
        };
        
        $(document).ready(function() {
            var timeseries = {{!timeseries}};
            var options = {
                    xaxis: {
                        show: false,
                    },
                    yaxis: {
                        tickFormatter: format_size
                    },
                    grid: {
                        hoverable: true
                    },
                    tooltip: true,
                    tooltipOpts: {
                        content: "%s | %y"
                    },
                    legend: {
                        position: "nw"
                    },
                    series: {
                        bars: {
                            show: true,
                            barWidth: .9,
                            fillColor: { colors: [ { opacity: 0.9 }, { opacity: 0.9 } ] },
                            align: "center"
                        },
                        stack: true
                    }
                };
            $.plot($('#memory_chart_flot'), timeseries, options);
        });
    </script>

    <h2>Snapshots statistics</h2>

    %for sn in snapshots:
        <h3>{{sn.desc or 'Untitled'}} snapshot at {{pp_timestamp(sn.timestamp)}}</h3>
        <table class="tdata">
            <thead>
                <tr>
                    <th width="20%">Class</th>
                    <th width="20%" class="num">Instance #</th>
                    <th width="20%" class="num">Total</th>
                    <th width="20%" class="num">Average size</th>
                    <th width="20%" class="num">Share</th>
                </tr>
            </thead>
            <tbody>
                %cnames = list(sn.classes.keys())
                %cnames.sort()
                %for cn in cnames:
                    %data = sn.classes[cn]
                    <tr>
                        <td><a href="/tracker/class/{{cn}}">{{cn}}</a></td>
                        <td class="num">{{data['active']}}</td>
                        <td class="num">{{pp(data['sum'])}}</td>
                        <td class="num">{{pp(data['avg'])}}</td>
                        <td class="num">{{'%3.2f%%' % data['pct']}}</td>
                    </tr>
                %end            
            </tbody>
        </table>

        %if sn.system_total.available:
            <h4>Process memory</h4>

            <table class="tdata">
                <thead>
                    <tr>
                        <th>Type</th>
                        <th class="num">Size</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>Virtual memory size</td>
                        <td class="num">{{pp(sn.system_total.vsz)}}</td>
                    </tr>
                    <tr>
                        <td>Resident set size</td>
                        <td class="num">{{pp(sn.system_total.rss)}}</td>
                    </tr>
                    <tr>
                        <td>Pagefaults</td>
                        <td class="num">{{sn.system_total.pagefaults}}</td>
                    </tr>
                    %for key, value in sn.system_total.os_specific:
                        <tr>
                            <td>{{key}}</td>
                            <td class="num">{{value}}</td>
                        </tr>
                    %end            
                </tbody>
            </table>
        %end
    %end

%else:

    <p>No objects are currently tracked. Consult the Pympler documentation for
    instructions of how to use the classtracker module.</p>

%end

%include('footer')