Sha256: 917887ef6a0224c4b626bb3ae82ad093227ee3820a6b59575eef05e5da648a6a
Contents?: true
Size: 1.23 KB
Versions: 8
Compression:
Stored size: 1.23 KB
Contents
if(!window['speedGun']) { window.speedGun = {}; }; speedGun.enableConsoleProfile = !!(window['console'] && console['profile']); speedGun.profileCount = 0; speedGun.profile = function(title, func) { speedGun.profileCount++; if(!func) { func = title; title = undefined; }; if(!title) { title = "Speed Gun Profile #" + speedGun.profileCount; }; var callstack = []; var caller = arguments['callee']; if(caller) { while(caller) { caller = caller['caller']; if(caller) { callstack.push(caller.toString()); }; } } var before = +(new Date); if(speedGun.enableConsoleProfile) { console.profile(title); }; ret = func(); if(speedGun.enableConsoleProfile) { console.profileEnd(title); }; var elapsedTime = (+(new Date)) - before; if(speedGun['send']) { speedGun.send( { js: { title: title, elapsed_time: elapsedTime, backtrace: callstack } } ); }; return ret; }; speedGun.profileMethod = function(object, methodName, title) { if(!title) { title = "#" + methodName; }; var method = object[methodName]; var func = function() { var args = arguments; return speedGun.profile(title, function() { return method.apply(object, args); }); }; object[methodName] = func; }
Version data entries
8 entries across 4 versions & 1 rubygems