Math-lookups

Benchmark created by bigfish on


Description

checking if aliasing Math.PI or Math.random makes things faster

Preparation HTML

<script>
  var rnd = Math.random;
  var PI = Math.PI;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Math.random
var p = {}

p.vx = Math.random() * 4 - 2;
p.vy = Math.random() * -5 - 3;
p.radius = Math.random() * 5 + 1;
p.threepi = Math.PI * 3;
ready
rnd
var p = {}

p.vx = rnd() * 4 - 2;
p.vy = rnd() * -5 - 3;
p.radius = rnd() * 5 + 1;

p.threepi = PI * 3;
ready

Revisions

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

  • Revision 1: published by bigfish on