MCPcopy Create free account
hub / github.com/apache/arrow / BM_ReplaceOld

Function BM_ReplaceOld

cpp/src/gandiva/tests/string_ops_benchmark.cc:124–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124void 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

Callers

nothing calls this directly

Calls 8

MakeTextFunction · 0.85
ExactCapacityFunction · 0.85
has_errorMethod · 0.80
get_errorMethod · 0.80
sizeMethod · 0.45
dataMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected