DEV Community

Discussion on: Bloom Filter in Javascript

Collapse
 
anders profile image
Anders

Never heard of a bloom filter before but its certainly interesting to learn about something new =)

However since constructing the structure there has a cost I think it would be more fair to include that in the timed section, in that scenario things don't look as good sadly. But it could certainly be useful if you have to construct it only once and need to do a lot more than 1000 checks.

I ran some local benhmarks here (Win 10, Chrome)

Traditional Search: 21.74609375 ms
Bloom Filter: 659.390869140625 ms (including setup)
Bloom Filter: 2.97900390625 ms (excluding setup)
Index Of: 1.644287109375 ms (your traditional search loop replaced with array.indexOf...)
For Loop: 4.094970703125 ms (your traditional search, but with a normal for loop instead of forEach)

Collapse
 
abhinpai profile image
Abhin Pai

Cool, honestly I tried neither foreach nor indexOf but these benchmarks seem to be quite interesting.

While digging into some more articles and posts I came to know that Bloom filter is more about saving the memory, I found one post in which he explained the purpose of it very neatly post

But as far as a construction concern, I guess it might be either prerequisite or cons of Bloom Filter but along with it, Bloom filter also says that we are not allowed to remove the data once it's fed into it according to wiki