What is the performance of std::bitset?

后端 未结 5 458
你的背包
你的背包 2020-12-24 05:24

I recently asked a question on Programmers regarding reasons to use manual bit manipulation of primitive types over std::bitset.

From that discussion I

5条回答
  •  别那么骄傲
    2020-12-24 05:39

    Not a great answer here, but rather a related anecdote:

    A few years ago I was working on real-time software and we ran into scheduling problems. There was a module which was way over time-budget, and this was very surprising because the module was only responsible for some mapping and packing/unpacking of bits into/from 32-bit words.

    It turned out that the module was using std::bitset. We replaced this with manual operations and the execution time decreased from 3 milliseconds to 25 microseconds. That was a significant performance issue and a significant improvement.

    The point is, the performance issues caused by this class can be very real.

提交回复
热议问题