gpt4 book ai didi

java - 具有类似数组的性能的 Java Bitset 替代品?

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:39:15 25 4
gpt4 key购买 nike

我正在寻找 Java Bitset 实现的替代方案。我正在实现一种高性能算法,似乎使用 Bitset 对象会降低其性能。有什么想法吗?

最佳答案

有人 hereboolean[]BitSet 进行了比较并得出结论:

BitSet is more memory efficient than boolean[] except for very small sizes. Each boolean in the array takes a byte. The numbers from runtime.freeMemory() are a bit muddled for BitSet, but less.

boolean[] is more CPU efficient except for very large sizes, where they are about even. E.g., for size 1 million boolean[] is about four times faster (e.g. 6ms vs 27ms), for ten and a hundred million they are about even.

如果你谷歌,你也可以找到一些替代实现,比如 JavaEWAH , 由 Apache Hive 使用, Apache SparkEclipse JGit .它声称:

The goal of word-aligned compression is not to achieve the best compression, but rather to improve query processing time. Hence, we try to save CPU cycles, maybe at the expense of storage. However, the EWAH scheme we implemented is always more efficient storage-wise than an uncompressed bitmap as implemented in the BitSet class). Unlike some alternatives, javaewah does not rely on a patented scheme.

关于java - 具有类似数组的性能的 Java Bitset 替代品?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8804435/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com