abs function mesure
by disfated
HTML
<script src="http://www.broofa.com/Tools/JSLitmus/JSLitmus.js"></script>
JavaScript
var test = JSLitmus.test.bind(JSLitmus);
Number.prototype.abs1 = function() {
return Math.abs(this);
};
Number.prototype.abs2 = function() {
return Math.abs(this.valueOf());
};
Number.prototype.abs3 = function() {
var val = this.valueOf();
return val < 0 ? -val : val;
};
var num = -100;
test('abs1', function(count) { while (count--) num.abs1() });
test('abs2', function(count) { while (count--) num.abs2() });
test('abs3', function(count) { while (count--) num.abs3() });
JSLitmus.runAll();