mixing boolean and int
JavaScript performance comparison
Info
Mixing booleans and ints can result in deopts. In the second test case, I pass through true or false rather than 1 or 0, and subsequent calls to t() run more slowly.
Preparation code
<script>
Benchmark.prototype.setup = function() {
var arr = new Uint32Array(10000);
function t(i, a) {
arr[i] = a;
}
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
All ints |
|
pending… |
Ints and bools |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published by Paul Holden
- Revision 2: published
0 comments