Math.pow vs. simple multiplication (v4)

Revision 4 of this benchmark created by SourceR on


Description

if you only need the square of something, what will eventually be faster?

Preparation HTML

<p>
  Hi there, this is math, only. No Output here
</p>
<script type="application/javascript;version=1.8">
  // JavaScript 1.8 is currently available only in Firefox
  function square18(x) x * x;
</script>
<script>
  var x1 = Math.random();

  function ownSquare(num) {
    return num * num;
  }
// fallback
if(!square18) var square18 = ownSquare;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Simple Multiplication
e = x1 * x1;
ready
Math.pow
e = Math.pow(x1, 2);
ready
own Pow
e = ownSquare(x1);
ready
Square from JS 1.8
e = square18(x1);
ready

Revisions

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