summaryrefslogtreecommitdiff
path: root/query/chart_global_counters.js
blob: cd5309d0d3b9f025fdf00bb4675ce1229c686fa3 (plain)
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
function GrasChartGlobalCounts(args, panel)
{
    //input checking
    if (args.block_ids.length != 0) throw gras_error_dialog(
        "GrasChartGlobalCounts",
        "Error making global counts chart.\n"+
        "Do not specify any blocks for this chart."
    );

    //settings
    this.div = $('<div />').attr({class:'chart_total_counts'});
    $(panel).append(this.div);
    this.title = "Global Counters"
}

GrasChartGlobalCounts.prototype.update = function(point)
{
    var ul = $('<ul />');
    $('ul', this.div).remove(); //clear old lists
    this.div.append(ul);

    function make_entry(strong, span)
    {
        var li = $('<li />');
        var strong = $('<strong />').text(strong + ": ");
        var span = $('<span />').text(span);
        li.append(strong);
        li.append(span);
        ul.append(li);
    }

    var allocator_stuff = [
        ['Allocated', 'bytes', 'default_allocator_bytes_allocated'],
        ['Peak size', 'bytes', 'default_allocator_peak_bytes_allocated'],
        ['Num mallocs', '', 'default_allocator_allocation_count'],
    ];
    var framework_stuff = [
        ['Total msgs', '', 'framework_counter_messages_processed'],
        ['Thread yields', '', 'framework_counter_yields'],
        ['Local pushes', '', 'framework_counter_local_pushes'],
        ['Shared pushes', '', 'framework_counter_shared_pushes'],
        ['Msg queue max', '', 'framework_counter_mailbox_queue_max'],
    ];

    var entries = 0;
    $.each(allocator_stuff, function(contents_i, contents)
    {
        var dir = contents[0];
        var units = contents[1];
        var key = contents[2];
        var count = (key in point)? point[key] : 0;
        if (count > 0)
        {
            make_entry(dir, count.toString() + ' ' + units);
            entries++;
        }
    });
    $.each(point.thread_pools, function(tp_i, tp_info)
    {
        make_entry('ThreadPool' + tp_i.toString(), '');
        $.each(framework_stuff, function(contents_i, contents)
        {
            var dir = contents[0];
            var units = contents[1];
            var key = contents[2];
            var count = (key in tp_info)? tp_info[key] : 0;
            if (count > 0)
            {
                make_entry(dir, count.toString() + ' ' + units);
                entries++;
            }
        });
    });
    if (entries == 0) make_entry("Counts", "none");
}