Make a random non-negative int64_t, avoiding the absent high bit and the low-entropy low bits produced by rand().
| 71 | // Make a random non-negative int64_t, avoiding the absent high bit and the low-entropy |
| 72 | // low bits produced by rand(). |
| 73 | int64_t MakeNonNegativeRand() { |
| 74 | int64_t result = (rand() >> 8) & 0x7fff; |
| 75 | result <<= 16; |
| 76 | result |= (rand() >> 8) & 0xffff; |
| 77 | result <<= 16; |
| 78 | result |= (rand() >> 8) & 0xffff; |
| 79 | result <<= 15; |
| 80 | result |= (rand() >> 8) & 0xffff; |
| 81 | return result; |
| 82 | } |
| 83 | |
| 84 | // Just benchmark the constructor and destructor cost |
| 85 | namespace bitmapinitialize { |