Monomorphic variable performance
JavaScript performance comparison
Info
In SpiderMonkey, if the type of a variable is monomorphic, it performs better
Preparation code
<script type="text/javascript">
function sumMonomorphic(a, b, c, d) {
var result = a;
result += b;
result += c;
result += d;
return result;
}
function sumDimorphic(a, b, c, d) {
var result;
result = a;
result += b;
result += c;
result += d;
return result;
}
function sumPolymorphic(a, b, c, d) {
var result;
result = null;
result = false;
result = "";
result = a;
result += b;
result += c;
result += d;
return result;
}
var count = 5000;
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Monomorphic local variable |
|
pending… |
Dimorphic local variable |
|
pending… |
Polymorphic local variable |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments