Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
|
|
@ -0,0 +1,47 @@
|
|||
define([], function () {
|
||||
return function debugTraceMethods(obj, moduleId, perfLogThreshold) {
|
||||
perfLogThreshold = perfLogThreshold || 0;
|
||||
var logQueue = [], logTimeoutId = 0;
|
||||
function logPerf() {
|
||||
logQueue.forEach(function (msg) {
|
||||
console.log(msg);
|
||||
});
|
||||
logQueue = [];
|
||||
logTimeoutId = 0;
|
||||
}
|
||||
function queueLog(prop, time, arg0) {
|
||||
var arg0Type = typeof arg0;
|
||||
logQueue.push(moduleId + ': ' + prop + (arg0Type === 'number' || arg0Type === 'boolean' || arg0Type === 'string' ? ': (' + arg0 + ')' : '') + (perfLogThreshold === 0 ? '' : ': ' + time));
|
||||
if (perfLogThreshold === 0) {
|
||||
logPerf();
|
||||
} else {
|
||||
if (!logTimeoutId) {
|
||||
logTimeoutId = setTimeout(logPerf, 2000);
|
||||
}
|
||||
}
|
||||
}
|
||||
function perfWrap(prop, fn) {
|
||||
return function () {
|
||||
var start = performance.now();
|
||||
if (perfLogThreshold === 0) {
|
||||
queueLog(prop, 0, arguments[0]);
|
||||
}
|
||||
var result = fn.apply(this, arguments);
|
||||
var end = performance.now();
|
||||
var time = end - start;
|
||||
if (perfLogThreshold > 0 && time > perfLogThreshold) {
|
||||
queueLog(prop, end - start, arguments[0]);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
if (perfLogThreshold > -1) {
|
||||
Object.keys(obj).forEach(function (prop) {
|
||||
var proto = obj;
|
||||
if (typeof proto[prop] === 'function') {
|
||||
proto[prop] = perfWrap(prop, proto[prop]);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
Loading…
Reference in a new issue