Closed oiime closed 5 years ago
It is an interesting approach which I did not know about... But...
Why would that be useful here?
Using values in a TypedArray is faster for allocation and setting and has a minimal memory footprint, it can also be initialized with 0 with no additional cost
and has operations such as set()
which can help manipulate arrays
for (let x = 1; x <= 100000; x++) {
const arr = new Array(10000)
// arr.fill(0)
for (let i = 0; i <= 10000; i++) {
arr[i] = 128
}
}
takes ~4s
for (let x = 1; x <= 100000; x++) {
const arr = new Uint8Array(10000)
arr.fill(0)
for (let i = 0; i <= 10000; i++) {
arr[i] = 128
}
}
takes ~0.8s
Please see... https://github.com/lemire/TypedFastBitSet.js
TypeFastBitSet uses a Uint32Array.
cool, thanks. would you mind if i take your code and do some major refactoring? i want to add some functionality and change the API
Sure you can. It is open source.
Hey,
Have you considered using the DataView type to store the bitset when available?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView