summaryrefslogtreecommitdiffstats
path: root/web/analysis/stats1.js
blob: 758b092fb783196f1bffb0be95c0d9da006ac7b1 (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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
function fetchStats(database, host, platform, branch, sha1, testCaseFilter) {
    updateStatus("fetching statistics ...", true);

    query = "?db=" + database +
        "&cmd=stats1" +
        "&host=" + encodeURIComponent(host) +
        "&platform=" + encodeURIComponent(platform) +
        "&branch=" + encodeURIComponent(branch) +
        "&sha1=" + sha1;
    if (testCaseFilter != "") {
        query += "&testcasefilter=" + testCaseFilter;
    }

    url = "http://" + location.host + "/cgi-bin/getstatswrapper" + query;
    // alert("url: >" + url + "<");

    $.ajax({
        url: url,
        type: "GET",
        dataType: "json",

        success: function(data, textStatus, request) {
            if (request.readyState == 4) {
                if (request.status == 200) {

                    if (data.error != null) {
                        updateStatus(
                            "fetching statistics ... failed: " +
                                data.error, false);
                        return
                    }

                    updateStatus("fetching statistics ... done", false);
                    updateStatus("", false);

                    // Show context ...
                    $("#shown_database").text(data.database);
                    $("#shown_host").text(data.host);
                    $("#shown_platform").text(data.platform);
                    $("#shown_branch").text(data.branch);
                    $("#shown_sha1").text(data.sha1);

                    // --- BEGIN Populate overall stats table ---
                    // 2 B DONE!
                    // --- END Populate overall stats table ---


                    // --- BEGIN Populate per-benchmark stats table ---

                    // Remove all rows below the header ...
                    $("#pbmTable tr:gt(0)").remove();

                    pbm_stats = data.per_bm_stats;

                    // Show # of per-benchmark rows ...
                    $("#pbmTable_nrows").text(pbm_stats.length);

                    // Insert new rows ...
                    html = "";
                    for (i = 0; i < pbm_stats.length; ++i) {
                        row = pbm_stats[i];
                        html += "<tr>";
                        for (j = 0; j < row.length; ++j) {

                            if (j > 8 && j < 19) {
                                if (row[j] < 0) {
                                    for (k = 0; k < 10; ++k) {
                                        html +=
                                        "<td style=\"color:#ff0000\">n/a</td>";
                                    }
                                    j = 18;
                                } else {
                                    html +=
                                    "<td " +
                                        "style=\"text-align:right\">" +
                                        row[j] + "</td>";
                                }
                            } else if (j <= 8) {
                                if (row[j] != "") {
                                    html +=
                                    "<td style=\"text-align:right\">" +
                                        row[j] + "</td>";
                                } else {
                                    html += "<td></td>";
                                }
                            } else if (j == 19) {
                                html += "<td class=\"metric\">" + row[j] +
                                    "</td>";
                            } else if (j > 19) {
                                html += "<td class=\"benchmark\">" + row[j] +
                                    "</td>";
                            } else {
                                html += "<td>" + row[j] + "</td>";
                            }
                        }
                        html += "</tr>";
                    }
                    $("#pbmTable > tbody:last").append(html);
                    $("#pbmTable").trigger("update");
                    $("#pbmTable").trigger("appendCache");

                    // var sorting = [[11,1],[0,0]];
                    //$("table").trigger("sorton",[sorting]);

                    // --- END Populate per-benchmark stats table ---


                    $("#div_shownContext").css("display", "block");
                    $("#div_statistics").css("display", "block");
                }
            }
        },

        error: function(request, textStatus, errorThrown) {
            descr = errorThrown;
            if (errorThrown == null) {
                descr = "undefined error - is the server down?";
            }
            updateStatus("fetching statistics ... error: " + descr, false);
        }

        // complete: function(request, textStatus) {
        //     alert("complete; request.status: " + request.status)
        // }

    });
}

$(document).ready(function() {

    $.tablesorter.addParser({
        id: "mixed_numeric",
        is: function(s) {
            return false; // so this parser is not auto detected
        },
        format: function(s) {
            f = parseFloat(s);
            if (isNaN(f)) { return ""; }
            return f.toFixed(20); // max precision guaranteed by ECMA standard
        },
        type: "numeric"
    });

    $("#pbmTable").tablesorter({
        headers: {
            // disable sorting:
            // 9: { sorter: false }, // histogram

            // handle proper sorting of mixed standard- and scientific notation:
            2: { sorter: "mixed_numeric" }, // min
            3: { sorter: "mixed_numeric" }, // max
            4: { sorter: "mixed_numeric" }, // median
            5: { sorter: "mixed_numeric" }, // mean
            6: { sorter: "mixed_numeric" }, // standard deviation
            7: { sorter: "mixed_numeric" }, // relative standard deviation
            8: { sorter: "mixed_numeric" }, // relative standard error
            9: { sorter: "mixed_numeric" }, // relative standard error
            10: { sorter: "mixed_numeric" }, // H0
            11: { sorter: "mixed_numeric" }, // H1
            12: { sorter: "mixed_numeric" }, // H2
            13: { sorter: "mixed_numeric" }, // H3
            14: { sorter: "mixed_numeric" }, // H4
            15: { sorter: "mixed_numeric" }, // H5
            16: { sorter: "mixed_numeric" }, // H6
            17: { sorter: "mixed_numeric" }, // H7
            18: { sorter: "mixed_numeric" }, // H8
            19: { sorter: "mixed_numeric" }  // H9
        }
    });

    $("#pbmTable").bind("sortStart",function() {
        $("#pbmTable_sortInProgress").show();
    }).bind("sortEnd",function() {
        $("#pbmTable_sortInProgress").hide();
    });

    args = queryStringArgs();

    // Extract database (required):
    database = extractArg(args, "db");
    if (database == "") {
        alert("ERROR: invalid query string (empty database)");
        return;
    }

    // Extract context (required):
    host = extractArg(args, "host");
    if (host == "") {
        alert("ERROR: invalid query string (empty host)");
        return;
    }
    platform = extractArg(args, "platform");
    if (platform == "") {
        alert("ERROR: invalid query string (empty platform)");
        return;
    }
    branch = extractArg(args, "branch");
    if (branch == "") {
        alert("ERROR: invalid query string (empty branch)");
        return;
    }
    sha1 = extractArg(args, "sha1");
    if (sha1 == "") {
        alert("ERROR: invalid query string (empty sha1)");
        return;
    }

    // Extract test case filter (optional);
    testCaseFilter = extractArg(args, "testcasefilter");

    $("#div_shownContext").css("display", "none");
    $("#div_statistics").css("display", "none");

    fetchStats(database, host, platform, branch, sha1, testCaseFilter);
});