window.measure takes an optional callback

This commit is contained in:
Corey Johnson 2012-01-30 16:16:18 -08:00
parent 8e77c05c06
commit 6319274284

View File

@ -4,9 +4,9 @@
<script src='src/stdlib/require.js'></script>
<script>
window.measure = function(name) {
window.measure = function(name, fn) {
var start = new Date().getTime();
return {stop: function() {
obj = {stop: function() {
var end = new Date().getTime();
var total = (end - start) / 1000;
while(name.length < 40) {
@ -14,6 +14,14 @@
}
console.log(name + (end - start) / 1000);
}}
if (fn) {
fn()
obj.stop()
}
else {
return obj
}
}
window.onload = function() {