Different bitstring representations can yield varying computational performance. This work compares three bitstring implementations in C++: std::bitset, boost::dynamic_bitset, and a custom direct implementation. Their performance is benchmarked in the context of concatenation within a Linear Genetic Programming system. Benchmarks were conducted on three platforms (macOS, Linux, and Windows MSYS2) to assess platform specific performance variations. The results show that the custom direct implementation delivers the fastest performance on Linux and Windows, while std::bitset performs best on macOS. Although consistently slower, boost::dynamic_bitset remains a viable and flexible option. These findings highlight the influence of compiler optimisations and system architecture on performance, providing practical guidance for selecting the optimal method based on platform and application requirements.
翻译:不同的比特串表示方法可能导致计算性能的差异。本研究比较了C++中的三种比特串实现:std::bitset、boost::dynamic_bitset以及一种自定义的直接实现。在基于线性遗传编程系统的连接操作背景下,对它们的性能进行了基准测试。测试在三个平台(macOS、Linux和Windows MSYS2)上进行,以评估平台特定的性能差异。结果表明,自定义直接实现在Linux和Windows上性能最快,而std::bitset在macOS上表现最佳。尽管boost::dynamic_bitset始终较慢,但它仍是一个可行且灵活的选择。这些发现突显了编译器优化和系统架构对性能的影响,为根据平台和应用需求选择最优方法提供了实用指导。