Multiple functions versus a single one

Benchmark created by PotHix on


Description

I just want to know how much memory is used to call a lot of functions instead of having just a big one.

Preparation HTML

<div id="text">
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
Multiple functions
global_var = 0;
function test1() {
  global_var++;
}

function test2() {
  global_var++;
}

function test3() {
  global_var++;
}

function test4(text) {
  global_var++;
}

function test5(text) {
  global_var++;
}

function test6(text) {
  global_var++;
}

function test7(text) {
  global_var++;
}

function test8(text) {
  global_var++;
}

function test9(text) {
  global_var++;
}

function test10(text) {
  global_var++;
}

test1();
test2();
test3();
test4();
test5();
test6();
test7();
test8();
test9();
test10();
document.getElementById("text").innerHTML = global_var;
ready
Single function
global_var = 0;
function test() {
  global_var++;
  global_var++;
  global_var++;
  global_var++;
  global_var++;
  global_var++;
  global_var++;
  global_var++;
  global_var++;
  global_var++;
}
test()
document.getElementById("text").innerHTML = global_var;
ready

Revisions

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