Created
January 27, 2012 05:14
-
-
Save rocktronica/1687126 to your computer and use it in GitHub Desktop.
JS function timer function, tinker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rotwang = (function ($, undefined) { | |
this.timers = {}; | |
this.addTime = function (sTime, iTime) { | |
this.timers[sTime] = this.timers[sTime] || []; | |
this.timers[sTime].push(iTime); | |
}; | |
this.averages = (function () { | |
$.each(this.timers, function (key, times) { | |
var iTotal = 0, iCount = 0; | |
$.each(times, function (i, time) { | |
iCount++; | |
iTotal += time; | |
}); | |
console.log(key + ' \tAverage:', Math.round(iTotal / iCount), ' \tTotal:', iTotal, ' \t Items:', iCount, times); | |
}); | |
}); | |
return this; | |
} (jQuery)); |
Author
rocktronica
commented
Jan 27, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment