SCons-custom-sig / timings / graph.html

  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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
<html>

<!--
  Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
  Use of this source code is governed by a BSD-style license that can be
  found in the LICENSE file.
-->

<!--
  A brief note on terminology as used here: a "graph" is a plotted screenful
  of data, showing the results of one type of test: for example, the
  page-load-time graph.  A "trace" is a single line on a graph, showing one
  one for the test: for example, the reference build trace on the
  page-load-time graph.

  This page plots arbitrary numerical data loaded from files in a specific
  format.  It uses two or more data files, all JSON-encoded:

    graphs.dat: a list of objects, each with these properties: name (the name
        of a graph) and units (the units for the data to be read by humans).
        Schematically:
          [{"name": <graph_name>, "units": <units>}, ...]

    <graphname>-summary.dat: for each of the graphs listed in graphs.dat, the
        corresponding summary file holds rows of data. Each row of data is an
        object with several properties:
          "rev": the revision number for this row of data
          "traces": an object with several properties of its own. The name of
              the property corresponds to a trace name, used only as an
              internal identifier, and the property's value is an array of
              its measurement and that measurement's standard deviation (or
              other measurement error).
        Schematically:
          {"rev": <rev>,
           "traces": {<trace_name1>: [<value1>, <stddev1>],
                      <trace_name2>: [<value2>, <stddev2>], ...}
          }
-->
<head>
<style>
body {
  font-family: sans-serif;
}
div#output {
  cursor: pointer;
}
div#switcher {
  cursor: pointer;
}
div#switcher a {
  border-top: 1px solid black;
  border-left: 1px solid black;
  padding-left: 0.5em;
  padding-right: 0.5em;
}
canvas.plot {
  border: 1px solid black;
}
div.plot-coordinates {
  font-family: monospace;
}
iframe {
  display: none;
  width: 100%;
  height: 100%;
  border: none;
}
div.selector {
  border: solid 1px black;
  cursor: pointer;
  padding-left: 0.3em;
  background-color: white;
}
div.selector:hover {
  background-color: rgb(200,200,250);
}
div.selected {
  border-left: none;
}
div#selectors {
  width: 80px;
  display: none;
}
#explain {
  font-size: 0.75em;
  font-style: italic;
  color: rgb(100,100,100);
}
</style>

<script src="js/common.js"></script>
<script src="js/plotter.js"></script>
<script src="js/coordinates.js"></script>
<script src="config.js"></script>
<script>
Config.source = "http://scons.tigris.org/svn/scons/trunk";
Config.changeLinkPrefix = "changelog.html?mode=html&range=";
Config.builder = "TODO";
Config.buildbotLink = "http://buildbot.scons.org:8010/";
Config.detailTabs = {'view-change': 'CL'};
document.title = Config.title + ' - ' + Config.buildslave;

var did_position_details = false;
var units = 'thing-a-ma-bobs';
var graph_list = [];
var first_trace = '';

var params = ParseParams();

function jsonToJs(data) {
  return eval('(' + data + ')')
}

function report_error(error) {
  document.getElementById("output").innerHTML = "<p>" + error + "</p>";
}

function received_graph_list(data, error) {
  if (error) {
    report_error(error);
    return;
  }
  graph_list = jsonToJs(data);

  if (!('graph' in params) || params.graph == '') {
    if (graph_list.length > 0)
      params.graph = graph_list[0].name
  }

  // Add a selection tab for each graph, and find the units for the selected
  // one while we're at it.
  tabs = [];
  for (var index = 0; index < graph_list.length; ++index) {
    var graph = graph_list[index];
    tabs.push(graph.name);
    if (graph.name == params.graph)
      units = graph.units;
  }
  initPlotSwitcher(tabs);

  // Fetch the data for the selected graph.
  fetch_summary();
}

function go_to(graph) {
  params.graph = graph;
  if (params.graph == '')
    delete params.graph;
  window.location.href = MakeURL(params);
}

function get_url() {
  new_url = window.location.href;
  new_url = new_url.replace(/\?lookout/, "?");
  new_url = new_url.replace(/\&thumbnail/, "");
  return new_url;
}

function on_clicked_plot(prev_cl, cl) {
  if ('lookout' in params) {
    window.open(get_url());
    return;
  }

  // Define sources for detail tabs
  if ('view-change' in Config.detailTabs) {
    document.getElementById('view-change').
        // TODO:  The tigris.org source browser only lets us pull up
        // one revision.  That's okay for our current behavior of
        // timing each revision separately, but if we go back to merging
        // build requests from multiple revisions, we'll need an
        // intermediary CGI script.
        //setAttribute('src', Config.changeLinkPrefix + prev_cl + ':' + cl);
        setAttribute('src',
          'http://scons.tigris.org/source/browse/scons?view=rev&revision=' + cl);
  }
  if ('view-pages' in Config.detailTabs) {
    document.getElementById('view-pages').
        setAttribute('src', 'details.html?cl=' + cl + '&trace=' + first_trace);
  }
  if ('view-coverage' in Config.detailTabs) {
    document.getElementById('view-coverage').
        setAttribute('src', Config.coverageLinkPrefix + cl);
  }

  if (!did_position_details) {
    position_details();
    did_position_details = true;
  }
}

function received_summary(data, error) {
  if (error) {
    report_error(error);
    return;
  }
  // Parse the summary data file.
  var rows = data.split('\n');
  var max_rows = rows.length;
  if ('history' in params && max_rows > params.history) {
      max_rows = params.history;
  } else if ('lookout' in params && max_rows > 150) {
    max_rows = 150;
  }

  var allTraces = {};

  // graphData[rev] = {trace1:[value, stddev], trace2:[value, stddev], ...}
  var graphData = {};
  for (var i = 0; i < max_rows; ++i) {
    if (!rows[i].length)
      continue;
    var row = jsonToJs(rows[i]);
    var traces = row['traces'];
    var revision = parseInt(row['rev']);
    graphData[revision] = traces;

    // Collect unique trace names.
    for (var traceName in traces)
      allTraces[traceName] = 1;
  }

  // Build a list of all the trace names we've seen, in the order in which
  // they appear in the data file. Although JS objects are not required by
  // the spec to iterate their properties in order, in practice they do,
  // because it causes compatibility problems otherwise.
  var traceNames = [];
  for (var traceName in allTraces)
    traceNames.push(traceName);

  first_trace = traceNames[0];

  // Build and numerically sort a list of revision numbers.
  var revisionNumbers = [];
  for (var rev in graphData)
    revisionNumbers.push(rev);
  revisionNumbers.sort(
      function(a, b) { return parseInt(a, 10) - parseInt(b, 10) });

  // Build separate ordered lists of trace data.
  var traceData = {};
  for (var revIndex = 0; revIndex < revisionNumbers.length; ++revIndex) {
    var rev = revisionNumbers[revIndex];
    var revisionData = graphData[rev];
    for (var nameIndex = 0; nameIndex < traceNames.length; ++nameIndex) {
      var traceName = traceNames[nameIndex];
      if (!traceData[traceName])
        traceData[traceName] = [];
      if (!revisionData[traceName])
        traceData[traceName].push([NaN, NaN]);
      else
        traceData[traceName].push(revisionData[traceName]);
    }
  }
  var plotData = [];
  for (var traceName in traceData)
    plotData.push(traceData[traceName]);

  var plotter = new Plotter(revisionNumbers, plotData, traceNames, units,
    document.getElementById("output"), true);
  plotter.onclick = on_clicked_plot;
  plotter.plot();
}

function fetch_summary() {
  if ('graph' in params)
    file = escape(params.graph) + ".dat"
  else
    file = "summary.dat"
  Fetch(file, received_summary);
}

function fetch_graph_list() {
  Fetch("graphs.dat", received_graph_list);
}

function initPlotSwitcher(tabs) {
  var switcher = document.getElementById("switcher");
  for(var i = 0; i < tabs.length; i++) {
    var anchor = document.createElement("a");
    anchor.appendChild(document.createTextNode(tabs[i] + " "));
    anchor.addEventListener("click", goToClosure(tabs[i]), false);
    switcher.appendChild(anchor);
  }
}

function goToClosure(graph) {
  return function(){go_to(graph)};
}

function position_details() {
  var output = document.getElementById("output");

  var win_height = window.innerHeight;

  var details = document.getElementById("views");

  var views = document.getElementById("views");
  var selectors = document.getElementById("selectors");
  selectors.style.display = "block";

  var views_width = output.offsetWidth - selectors.offsetWidth;

  views.style.border = "1px solid black";
  views.style.width = views_width + "px";
  views.style.height = (win_height - output.offsetHeight - output.offsetTop -
                        30) + "px";

  selectors.style.position = "absolute";
  selectors.style.left = (views.offsetLeft + views_width + 1) + "px";
  selectors.style.top = views.offsetTop + "px";

  // Change to the first detail tab
  for (var tab in Config.detailTabs) {
    change_view(tab);
    break; 
  }
}

function change_view(target) {
  for (var tab in Config.detailTabs) {
    document.getElementById(tab).style.display = 
        (tab == target ? "block" : "none");
  }
}

function init() {
  // We need to fill the graph list before parsing the params or fetching the
  // data, so we have a default graph in case none was specified.
  fetch_graph_list();
}

window.addEventListener("load", init, false);
</script>
</head>


<body>
<div id="header_lookout" align="center">
  <font style='color: #0066FF; font-family: Arial, serif;
               font-size: 20pt; font-weight: bold;'>
    <script>
      document.write("<a target=\"_blank\" href=\"");
      document.write(get_url());
      document.write("\">");
      if ('header' in params && params.header != '') {
        document.write(escape(params.header));
      } else {
        document.write(Config.title);
      }
      document.write("</a>");
    </script>
  </font>
</div>

<div id="header_text">
<script>
document.write('<a href="' + Config.buildbotLink + '">SCons buildbot</a>' +
               ' timings for the <b>' + Config.title + '</b> configuration.')
if ('graph' in params)
  document.write('  Displaying values for <b>' + params.graph + '</b>.');
</script>
</div>

<div id="explain">
The vertical axis is measured values, and the horizontal
axis is the revision number being tested.
</div>
<p></p>
<div id="switcher">

</div>
<div id="output"></div>
<div id="details">
  <div id="views">
    <script>
      for (var tab in Config.detailTabs) {
        document.write("<iframe id=\"" + tab + "\"></iframe>");
      }
    </script>
  </div>
  <div id="selectors">
    <script>
      var firstTab = true;
      for (var tab in Config.detailTabs) {
        document.write("<div ");
	if (firstTab) {
	  firstTab = false;
	} else {
	  document.write("style=\"border-top: none\" ");
	}
	document.write("class=\"selector\" onclick=\"change_view('" 
	    + tab + "')\">" + Config.detailTabs[tab] + "</div>");
      }
    </script>
  </div>
</div>
<pre id="log"></pre>
<script>
if ('lookout' in params) {
  document.getElementById("switcher").style.display = "none";
  document.getElementById("details").style.display = "none";
  document.getElementById("header_text").style.display = "none";
  document.getElementById("explain").style.display = "none";
  if ('thumbnail' in params) {
    document.getElementById("header_lookout").style.display = "none";
  }
} else {
  document.getElementById("header_lookout").style.display = "none";
}
</script>
</body>
</html>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.