diff options
author | Steven Knight <knight@baldmt.com> | 2009-12-18 08:03:50 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2009-12-18 08:03:50 (GMT) |
commit | 66d0823dd960afe9cf45c910d2fcedea133c6fef (patch) | |
tree | 6e1f3e3dd9a03cf38faa62500cd224b751d27905 /timings/js/common.js | |
parent | a158bdde183073bb22007d08b4a7cfa1163f082a (diff) | |
download | SCons-66d0823dd960afe9cf45c910d2fcedea133c6fef.zip SCons-66d0823dd960afe9cf45c910d2fcedea133c6fef.tar.gz SCons-66d0823dd960afe9cf45c910d2fcedea133c6fef.tar.bz2 |
Move the timings-specific pieces of the buildbot infrastructure into
the trunk/timings directory. We'll map them into the buildbot directory
using svn:externals. This will let us keep all the pieces of a timing
configuration, including its buildbot pieces, in one place, and will
let us simplify the Master initialization (since it will be able to look
on-disk for the configurations for which it should set up buildbot steps,
instead of querying the SVN server).
Diffstat (limited to 'timings/js/common.js')
-rw-r--r-- | timings/js/common.js | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/timings/js/common.js b/timings/js/common.js new file mode 100644 index 0000000..80510b3 --- /dev/null +++ b/timings/js/common.js @@ -0,0 +1,96 @@ +/* + Copyright (c) 2006-2008 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. +*/ + +/* + Common methods for performance-plotting JS. +*/ + +function Fetch(url, callback) { + var r = new XMLHttpRequest(); + r.open("GET", url, true); + r.setRequestHeader("pragma", "no-cache"); + r.setRequestHeader("cache-control", "no-cache"); + r.onreadystatechange = function() { + if (r.readyState == 4) { + var error; + var text = r.responseText; + if (r.status != 200) { + error = url + ": " + r.status + ": " + r.statusText; + } else if (! text) { + error = url + ": null response"; + } + callback(text, error); + } + } + + r.send(null); +} + +// Returns the keys of an object. +function Keys(obj) { + result = []; + for (key in obj) { + result.push(key) + } + return result +} + +// Returns the "directory name" portion of the string (URL), +// stripping the last element. +function DirName(s) { + elements = s.split('/') + elements.pop() + return elements.join('/') +} + +// Returns an Object with properties given by the parameters specified in the +// URL's query string. +function ParseParams() { + var result = new Object(); + var s = window.location.search.substring(1).split('&'); + for (i = 0; i < s.length; ++i) { + var v = s[i].split('='); + result[v[0]] = unescape(v[1]); + } + return result; +} + +// Creates the URL constructed from the current pathname and the given params. +function MakeURL(params) { + var url = window.location.pathname; + var sep = '?'; + for (p in params) { + if (!p) + continue; + url = url + sep + p + '=' + params[p]; + sep = '&'; + } + return url; +} + +// Returns a string describing an object, recursively. On the initial call, +// |name| is optionally the name of the object and |indent| is not needed. +function DebugDump(obj, opt_name, opt_indent) { + var name = opt_name || ''; + var indent = opt_indent || ''; + if (typeof obj == "object") { + var child = null; + var output = indent + name + "\n"; + + for (var item in obj) { + try { + child = obj[item]; + } catch (e) { + child = "<Unable to Evaluate>"; + } + output += DebugDump(child, item, indent + " "); + } + + return output; + } else { + return indent + name + ": " + obj + "\n"; + } +} |