function scope

Benchmark created on


Preparation HTML

<script>
  function gSubstitute(string, number) {
      return string.replace('%', number);
  }
  
  
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
global
function test() {
    for (var i = 0; i < 20; i++) {
    gSubstitute('sfadsg % dsgafdhfdh', 'dsagd');
    }
}

test();
ready
local
function test() {
    var sub = gSubstitute;

    for (var i = 0; i < 20; i++) {
    sub('sfadsg % dsgafdhfdh', 'dsagd');
    }
}

test();
ready
function test() {
function substitute(string, number) {
    return string.replace('%', number);
}

    for (var i = 0; i < 20; i++) {
    substitute('sfadsg % dsgafdhfdh', 'dsagd');
    }
}

test();
ready

Revisions

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