Number vs parseFloat

Benchmark created by Luke Alonso on


Preparation HTML

<script>
  var n = [-0.707, 1.0, -1.0, 0, 0.707, 0.33, 0.66];
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Number
var n0 = Number(n[0]);
var n1 = Number(n[1]);
var n2 = Number(n[2]);
var n3 = Number(n[3]);
var n4 = Number(n[4]);
var n5 = Number(n[5]);
var n6 = Number(n[6]);
var n7 = n0 + n1 * n2 - n3 / n4 + n5;
var n8 = n0 + n1 * n2 - n3 / n4 + n5;
var n9 = n0 + n1 * n2 - n3 / n4 + n5;
var n10 = n0 + n1 * n2 - n3 / n4 + n5;
var n11 = n0 + n1 * n2 - n3 / n4 + n5;
var n12 = n0 + n1 * n2 - n3 / n4 + n5;
var n13 = n0 + n1 * n2 - n3 / n4 + n5;
var n14 = n0 + n1 * n2 - n3 / n4 + n5;
ready
parseFloat
var n0 = parseFloat(n[0]);
var n1 = parseFloat(n[1]);
var n2 = parseFloat(n[2]);
var n3 = parseFloat(n[3]);
var n4 = parseFloat(n[4]);
var n5 = parseFloat(n[5]);
var n6 = parseFloat(n[6]);
var n7 = n0 + n1 * n2 - n3 / n4 + n5;
var n8 = n0 + n1 * n2 - n3 / n4 + n5;
var n9 = n0 + n1 * n2 - n3 / n4 + n5;
var n10 = n0 + n1 * n2 - n3 / n4 + n5;
var n11 = n0 + n1 * n2 - n3 / n4 + n5;
var n12 = n0 + n1 * n2 - n3 / n4 + n5;
var n13 = n0 + n1 * n2 - n3 / n4 + n5;
var n14 = n0 + n1 * n2 - n3 / n4 + n5;
ready
none
var n0 = (n[0]);
var n1 = (n[1]);
var n2 = (n[2]);
var n3 = (n[3]);
var n4 = (n[4]);
var n5 = (n[5]);
var n6 = (n[6]);
var n7 = n0 + n1 * n2 - n3 / n4 + n5;
var n8 = n0 + n1 * n2 - n3 / n4 + n5;
var n9 = n0 + n1 * n2 - n3 / n4 + n5;
var n10 = n0 + n1 * n2 - n3 / n4 + n5;
var n11 = n0 + n1 * n2 - n3 / n4 + n5;
var n12 = n0 + n1 * n2 - n3 / n4 + n5;
var n13 = n0 + n1 * n2 - n3 / n4 + n5;
var n14 = n0 + n1 * n2 - n3 / n4 + n5;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.