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

Function BM_ReplaceNew

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

Source from the content-addressed store, hash-verified

94}
95
96void BM_ReplaceNew(benchmark::State& state) {
97 const ReplaceCase& c = Cases()[state.range(0)];
98 auto flen = static_cast<int>(strlen(c.from));
99 auto olen = static_cast<int>(strlen(c.to));
100 std::string text = MakeText(c.text_len, c.stride, c.from[0], 'x');
101 auto tlen = static_cast<int32_t>(text.size());
102 ExecutionContext ctx;
103 auto ctx_ptr = reinterpret_cast<int64_t>(&ctx);
104
105 // One warm-up call doubling as a correctness guard.
106 int32_t out_len = 0;
107 replace_utf8_utf8_utf8(ctx_ptr, text.data(), tlen, c.from, flen, c.to, olen, &out_len);
108 if (ctx.has_error()) {
109 state.SkipWithError(ctx.get_error().c_str());
110 return;
111 }
112
113 for (auto _ : state) {
114 ctx.Reset();
115 const char* out = replace_utf8_utf8_utf8(ctx_ptr, text.data(), tlen, c.from, flen,
116 c.to, olen, &out_len);
117 benchmark::DoNotOptimize(out);
118 benchmark::DoNotOptimize(out_len);
119 }
120 state.SetBytesProcessed(state.iterations() * tlen);
121 state.SetLabel(c.name);
122}
123
124void BM_ReplaceOld(benchmark::State& state) {
125 const ReplaceCase& c = Cases()[state.range(0)];

Callers

nothing calls this directly

Calls 7

MakeTextFunction · 0.85
replace_utf8_utf8_utf8Function · 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