Cost of a function-invocation
JavaScript performance comparison
Info
Measures the cost of calling a function over not calling it
Preparation code
<script>
Benchmark.prototype.setup = function() {
function addition(num) {
return num + 1;
}
function additionWithNoParams() {
count++;
}
function lazyGitWhoDoesNothing() {
}
var count = 0;
var iterations = 1000;
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Without function |
|
pending… |
With function |
|
pending… |
With function, no params |
|
pending… |
A no operation function |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments