minor perf. improvements

This commit is contained in:
Mihai Bazon
2012-09-02 11:11:39 +03:00
parent 52bcca288f
commit 24bfd55a22
2 changed files with 33 additions and 26 deletions

View File

@@ -46,11 +46,12 @@ function curry(f) {
return function() { return f.apply(this, args.concat(slice(arguments))); };
};
function prog1(ret) {
function prog1(ret, f1, f2, f3) {
if (ret instanceof Function)
ret = ret();
for (var i = 1, n = arguments.length; --n > 0; ++i)
arguments[i]();
if (f1) f1();
if (f2) f2();
if (f3) f3();
return ret;
};
@@ -169,3 +170,9 @@ function string_template(text, props) {
return props[p];
});
};
function time_it(name, cont) {
var t1 = new Date().getTime();
try { return cont(); }
finally { sys.debug("// " + name + ": " + ((new Date().getTime() - t1) / 1000).toFixed(3) + " sec."); }
};