Closed ebrensi closed 3 years ago
Here are relevant benchmarks from my laptop
starting inplace change (XOR) benchmark
FastBitSet (inplace) x 90.15 ops/sec ±0.31% (79 runs sampled)
infusion.BitSet.js (inplace) x 0.79 ops/sec ±2.85% (6 runs sampled)
tdegrunt.BitSet (inplace) x 0.78 ops/sec ±4.55% (6 runs sampled)
roaring x 432 ops/sec ±1.14% (97 runs sampled)
Set (inplace) x 4.23 ops/sec ±3.03% (15 runs sampled)
starting change (XOR) query benchmark
roaring x 1,064 ops/sec ±39.31% (42 runs sampled)
FastBitSet (creates new bitset) x 26.86 ops/sec ±3.93% (50 runs sampled)
mattkrick.fast-bitset (creates new bitset) x 10.18 ops/sec ±7.47% (30 runs sampled)
Set x 1.99 ops/sec ±4.48% (10 runs sampled)
starting inplace difference benchmark
FastBitSet (inplace) x 7,865 ops/sec ±8.90% (100 runs sampled)
FastBitSet (inplace2) x 7,274 ops/sec ±7.82% (99 runs sampled)
TypedFastBitSet (inplace) x 6,503 ops/sec ±2.89% (97 runs sampled)
infusion.BitSet.js (inplace) x 19.36 ops/sec ±8.89% (37 runs sampled)
tdegrunt.BitSet (inplace) x 22.18 ops/sec ±5.03% (40 runs sampled)
roaring x 50,038 ops/sec ±1.19% (94 runs sampled)
Set (inplace) x 4.42 ops/sec ±2.36% (16 runs sampled)
Looks good. Please consider my specific comment above.
Hello again and happy new year. In this pull request I have
Changed all
var
statements to the modernlet
andconst
where appropriate, in the module itself and the tests and benchmarks.Added a
FastBitSet.fromWords
constructor, for creating a newFastBitSet
if we already have words. Actually this is meant more for the TypedArray version, which I will make a pull request for soon.Added a (sort of) new method called
difference2
. The difference method (AND NOT) is not commutative like the other operations, so the existing in-place operation may modify the wrong object for a potential use. In my case, I am monitoring new changes from one moment to the next, so I want to modify the oldFastBitSet
, not the new one. ForFastBitSet
objectsA
andB
,A.difference2(B)
performs the same operation asA.difference(B)
, in-place, except it modifiesB
instead ofA
. I made it into a new method instead of modifying the existing one because I did not want to affect performance of the original one, which is faster.difference2
is slower thandifference
, but it is still much faster thannew_difference
.Added benchmarks for the
change
andnew_change
(XOR) methods that I introduced in my last pull request.After running the benchmarks I discovered that
change
and especiallynew_change
were too slow, so I made them both more efficient.Added all the required libraries for Benchmarking into
package.json
dev-dependencies, and a newnpm run benchmark
script, making it easy to run benchmarks.Note: I disabled the
infusion.BitSet.js
benchmark forArrayBench()
because for some reason it was making my laptop hang.