MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / BM_StringConcat

Function BM_StringConcat

eval/tests/expression_builder_benchmark_test.cc:378–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

376 ->Arg(BenchmarkParam::kRecursivePlanningWithConstantFolding);
377
378void BM_StringConcat(benchmark::State& state) {
379 auto param = static_cast<BenchmarkParam>(state.range(0));
380 state.SetLabel(LabelForParam(param));
381 auto size = state.range(1);
382
383 std::string source = "'1234567890' + '1234567890'";
384 auto height = static_cast<int>(std::log2(size));
385 for (int i = 1; i < height; i++) {
386 // Force the parse to be a binary tree, otherwise we can hit
387 // recursion limits.
388 source = absl::StrCat("(", source, " + ", source, ")");
389 }
390
391 // add a non const branch to the expression.
392 absl::StrAppend(&source, " + identifier");
393
394 ASSERT_OK_AND_ASSIGN(ParsedExpr expr, parser::Parse(source));
395
396 google::protobuf::Arena arena;
397 InterpreterOptions options = OptionsForParam(param, arena);
398
399 auto builder = CreateCelExpressionBuilder(options);
400 auto reg_status = RegisterBuiltinFunctions(builder->GetRegistry());
401 ASSERT_OK(reg_status);
402
403 for (auto _ : state) {
404 ASSERT_OK_AND_ASSIGN(
405 auto expression,
406 builder->CreateExpression(&expr.expr(), &expr.source_info()));
407 arena.Reset();
408 }
409}
410
411BENCHMARK(BM_StringConcat)
412 ->Args({BenchmarkParam::kDefault, 2})

Callers

nothing calls this directly

Calls 6

LabelForParamFunction · 0.85
OptionsForParamFunction · 0.85
RegisterBuiltinFunctionsFunction · 0.85
GetRegistryMethod · 0.80
ResetMethod · 0.45

Tested by

no test coverage detected