| 951 | BENCHMARK(BM_ListComprehension)->Range(1, 1 << 16); |
| 952 | |
| 953 | void BM_ListComprehension_Trace(benchmark::State& state) { |
| 954 | google::protobuf::Arena arena; |
| 955 | Activation activation; |
| 956 | ASSERT_OK_AND_ASSIGN(ParsedExpr parsed_expr, |
| 957 | parser::Parse("list_var.map(x, x * 2)")); |
| 958 | |
| 959 | int len = state.range(0); |
| 960 | std::vector<CelValue> list; |
| 961 | list.reserve(len); |
| 962 | for (int i = 0; i < len; i++) { |
| 963 | list.push_back(CelValue::CreateInt64(1)); |
| 964 | } |
| 965 | |
| 966 | ContainerBackedListImpl cel_list(std::move(list)); |
| 967 | activation.InsertValue("list_var", CelValue::CreateList(&cel_list)); |
| 968 | InterpreterOptions options = GetOptions(arena); |
| 969 | options.comprehension_max_iterations = 10000000; |
| 970 | options.enable_comprehension_list_append = true; |
| 971 | options.enable_recursive_tracing = true; |
| 972 | |
| 973 | auto builder = CreateCelExpressionBuilder(options); |
| 974 | ASSERT_OK(RegisterBuiltinFunctions(builder->GetRegistry(), options)); |
| 975 | ASSERT_OK_AND_ASSIGN( |
| 976 | auto cel_expr, builder->CreateExpression(&(parsed_expr.expr()), nullptr)); |
| 977 | |
| 978 | for (auto _ : state) { |
| 979 | ASSERT_OK_AND_ASSIGN(CelValue result, |
| 980 | cel_expr->Trace(activation, &arena, EmptyCallback)); |
| 981 | ASSERT_TRUE(result.IsList()); |
| 982 | ASSERT_EQ(result.ListOrDie()->size(), len); |
| 983 | } |
| 984 | } |
| 985 | |
| 986 | BENCHMARK(BM_ListComprehension_Trace)->Range(1, 1 << 16); |
| 987 |
nothing calls this directly
no test coverage detected