Cleaned up probe code a little.

This commit is contained in:
Robin Ward 2013-03-11 11:13:28 -04:00
parent 37cf8b7d38
commit 4360d1bd61
4 changed files with 1565 additions and 1572 deletions

View File

@ -29,50 +29,44 @@ Discourse.Development = {
}, },
after: function(data, owner, args) { after: function(data, owner, args) {
var ary, f, n, v, _ref;
if (typeof console === "undefined") return;
if (console === null) return;
var f, n, v;
if (owner && data.time > 10) { if (owner && data.time > 10) {
f = function(name, data) { f = function(name, data) {
if (data && data.count) return name + " - " + data.count + " calls " + ((data.time + 0.0).toFixed(2)) + "ms"; if (data && data.count) return name + " - " + data.count + " calls " + ((data.time + 0.0).toFixed(2)) + "ms";
}; };
if (console && console.group) { if (console.group) {
console.group(f(name, data)); console.group(f(name, data));
} else { } else {
console.log(""); console.log("");
console.log(f(name, data)); console.log(f(name, data));
} }
ary = []; var ary = [];
_ref = window.probes; for (n in window.probes) {
for (n in _ref) { v = window.probes[n];
v = _ref[n]; if (n === name || v.time < 1) continue;
if (n === name || v.time < 1) { ary.push({ k: n, v: v });
continue;
}
ary.push({
k: n,
v: v
});
} }
ary.sortBy(function(item) { ary.sortBy(function(item) {
if (item.v && item.v.time) { if (item.v && item.v.time) return -item.v.time;
return -item.v.time;
} else {
return 0; return 0;
}
}).each(function(item) { }).each(function(item) {
var output = f("" + item.k, item.v); var output = f("" + item.k, item.v);
if (output) { if (output) {
return console.log(output); console.log(output);
} }
}); });
if (typeof console !== "undefined" && console !== null) {
if (typeof console.groupEnd === "function") { if (console.group) {
console.groupEnd(); console.groupEnd();
} }
} window.probes.clear();
return window.probes.clear();
} }
} }
}); });

View File

@ -92,8 +92,7 @@
start = now(); start = now();
callStart = start; callStart = start;
} }
else if(after) else if(after) {
{
callStart = now(); callStart = now();
} }