Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Powers of two
(version: 0)
If they should be written in an array or in the loop as we go
Comparing performance of:
for with if vs 2x for vs 2x for charcode-48
Created:
8 years ago
by:
Guest
Jump to the latest result
Tests:
for with if
var j = "MSKU947765"; var s = 0; var r = [1,2,4,8,16,32,64,128,256,512]; for (var e=0;e<10;e++) { if (e<4) { var c = j.charCodeAt(e)-55; s+=(Math.floor(c/10.2)+c)*r[e]; } else { s+=Number(j.charAt(e))*r[e]; }; }; var d = s % 11 % 10; return d;
2x for
var j = "MSKU947765"; var s = 0; var r = [1,2,4,8,16,32,64,128,256,512]; for (var e=0;e<4;e++) { var c = j.charCodeAt(e)-55; s+=(Math.floor(c/10.2)+c)*r[e]; }; for (var f=0;f<6;f++){ s+=Number(j.charAt(e))*r[e]; }; var d = s % 11 % 10; return d;
2x for charcode-48
var j = "MSKU947765"; var s = 0; var r = [1,2,4,8,16,32,64,128,256,512]; for (var e=0;e<4;e++) { var c = j.charCodeAt(e)-55; s+=(Math.floor(c/10.2)+c)*r[e]; }; for (var f=0;f<6;f++){ s+=(j.charCodeAt(e)-48)*r[e]; }; var d = s % 11 % 10; return d;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
for with if
2x for
2x for charcode-48
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
Powers of two
Powers of two
pow vs multiply v2
Math.pow(2,n) vs Table lookup vs bitwise
Math.pow vs multiplication with decimals and multiple integers
Comments
Confirm delete:
Do you really want to delete benchmark?