Cached Math vs Global (v2)

Revision 2 of this benchmark created by Daniel Davis on


Preparation HTML

<script>
  var cachedMath = function() {
      var m = Math;
      return m.pow(2, 8) + m.sqrt(16) + m.PI;
      };
  
  var globalMath = function() {
      var m = Math;
      return Math.pow(2, 8) + Math.sqrt(16) + Math.PI
      };
  
  var m2 = Math;
  var cachedMath2 = function() {
      return m2.pow(2, 8) + m2.sqrt(16) + m2.PI;
      };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Cached Math
var n = cachedMath();
ready
Global Math
var n = globalMath();
ready
Cached Math 2
var n = cachedMath2();
ready

Revisions

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