Comparing custom and bultin Math.round
JavaScript performance comparison
Info
See: http://stackoverflow.com/q/8483357/1011582
Custom Math.round implementation is:
R1(a,b){var c=a%b;return ac+(c/b+1.5>>1)*b}
Preparation code
<script>
Benchmark.prototype.setup = function() {
function R1(a,b){var c=a%b;return ac+(c/b+1.5>>1)*b}
R2 = Math.round;
function R3(a){return Math.round(a)}
tally = 0
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
Test  Ops/sec  

Custom Math.round 

pending… 
Builtin Math.round (direct) 

pending… 
Builtin Math.round (wrapped) 

pending… 
Custom Math.round #OPT 

pending… 
Builtin Math.round (direct) #OPT 

pending… 
Builtin Math.round (wrapped) #OPT 

pending… 
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit
to the URL. Here’s a list of current revisions for this page:
 Revision 1: published
 Revision 2: published
 Revision 3: published
 Revision 4: published
 Revision 5: published
 Revision 6: published
 Revision 7: published
0 comments
Comment form temporarily disabled.