| 60 | return result; |
| 61 | } |
| 62 | static StringPiece CompressibleString(random::SimplePhilox* rnd, |
| 63 | double compressed_fraction, size_t len, |
| 64 | string* dst) { |
| 65 | int raw = static_cast<int>(len * compressed_fraction); |
| 66 | if (raw < 1) raw = 1; |
| 67 | string raw_data; |
| 68 | RandomString(rnd, raw, &raw_data); |
| 69 | |
| 70 | // Duplicate the random data until we have filled "len" bytes |
| 71 | dst->clear(); |
| 72 | while (dst->size() < len) { |
| 73 | dst->append(raw_data); |
| 74 | } |
| 75 | dst->resize(len); |
| 76 | return StringPiece(*dst); |
| 77 | } |
| 78 | } // namespace test |
| 79 | |
| 80 | static void Increment(string* key) { key->push_back('\0'); } |