Int as boolean array (via bitmasks)
JavaScript performance comparison
Info
The usage of a single integer, as a boolean array (up to 31 booleans).
Preparation code
<script>
Benchmark.prototype.setup = function() {
var boolArr = new Array(31);
var boolInt = 0;
var bitMaskArr = new Array(31);
var _a = 0,
_b, _c, _d;
for (_a = 0; _a < 31; ++_a) {
boolArr[_a] = false;
bitMaskArr[_a] = Math.pow(2, _a);
}
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
boolArr set 0 index true |
|
pending… |
boolInt set 0 index true |
|
pending… |
boolArr set all true |
|
pending… |
boolInt set all true (Math.pow) |
|
pending… |
boolInt set all true (parseInt) |
|
pending… |
boolInt set all true (direct multiplication) |
|
pending… |
boolInt set all true (bitmask array) |
|
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 picocreator
- Revision 2: published by picocreator
- Revision 3: published by picocreator
0 comments