| 122 | } |
| 123 | |
| 124 | void BM_ReplaceOld(benchmark::State& state) { |
| 125 | const ReplaceCase& c = Cases()[state.range(0)]; |
| 126 | auto flen = static_cast<int>(strlen(c.from)); |
| 127 | auto olen = static_cast<int>(strlen(c.to)); |
| 128 | std::string text = MakeText(c.text_len, c.stride, c.from[0], 'x'); |
| 129 | auto tlen = static_cast<int32_t>(text.size()); |
| 130 | int32_t capacity = ExactCapacity(text, c.from, flen, olen); |
| 131 | ExecutionContext ctx; |
| 132 | auto ctx_ptr = reinterpret_cast<int64_t>(&ctx); |
| 133 | |
| 134 | int32_t out_len = 0; |
| 135 | replace_with_max_len_utf8_utf8_utf8(ctx_ptr, text.data(), tlen, c.from, flen, c.to, |
| 136 | olen, capacity, &out_len); |
| 137 | if (ctx.has_error()) { |
| 138 | state.SkipWithError(ctx.get_error().c_str()); |
| 139 | return; |
| 140 | } |
| 141 | |
| 142 | for (auto _ : state) { |
| 143 | ctx.Reset(); |
| 144 | const char* out = replace_with_max_len_utf8_utf8_utf8( |
| 145 | ctx_ptr, text.data(), tlen, c.from, flen, c.to, olen, capacity, &out_len); |
| 146 | benchmark::DoNotOptimize(out); |
| 147 | benchmark::DoNotOptimize(out_len); |
| 148 | } |
| 149 | state.SetBytesProcessed(state.iterations() * tlen); |
| 150 | state.SetLabel(c.name); |
| 151 | } |
| 152 | |
| 153 | } // namespace |
| 154 |
nothing calls this directly
no test coverage detected