| 376 | ->Arg(BenchmarkParam::kRecursivePlanningWithConstantFolding); |
| 377 | |
| 378 | void 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 | |
| 411 | BENCHMARK(BM_StringConcat) |
| 412 | ->Args({BenchmarkParam::kDefault, 2}) |
nothing calls this directly
no test coverage detected