| 1016 | BENCHMARK(BM_NestedComprehension_Trace)->Range(1, 1 << 10); |
| 1017 | |
| 1018 | void BM_ListComprehension(benchmark::State& state) { |
| 1019 | ASSERT_OK_AND_ASSIGN(ParsedExpr parsed_expr, Parse("list_var.map(x, x * 2)")); |
| 1020 | |
| 1021 | RuntimeOptions options = GetOptions(); |
| 1022 | options.comprehension_max_iterations = 10000000; |
| 1023 | options.enable_comprehension_list_append = true; |
| 1024 | auto runtime = StandardRuntimeOrDie(options); |
| 1025 | |
| 1026 | ASSERT_OK_AND_ASSIGN(auto cel_expr, ProtobufRuntimeAdapter::CreateProgram( |
| 1027 | *runtime, parsed_expr)); |
| 1028 | |
| 1029 | google::protobuf::Arena arena; |
| 1030 | Activation activation; |
| 1031 | |
| 1032 | auto list_builder = cel::NewListValueBuilder(&arena); |
| 1033 | |
| 1034 | int len = state.range(0); |
| 1035 | list_builder->Reserve(len); |
| 1036 | for (int i = 0; i < len; i++) { |
| 1037 | ASSERT_THAT(list_builder->Add(IntValue(1)), IsOk()); |
| 1038 | } |
| 1039 | |
| 1040 | activation.InsertOrAssignValue("list_var", std::move(*list_builder).Build()); |
| 1041 | |
| 1042 | for (auto _ : state) { |
| 1043 | ASSERT_OK_AND_ASSIGN(cel::Value result, |
| 1044 | cel_expr->Evaluate(&arena, activation)); |
| 1045 | ASSERT_TRUE(InstanceOf<ListValue>(result)); |
| 1046 | ASSERT_THAT(Cast<ListValue>(result).Size(), IsOkAndHolds(len)); |
| 1047 | } |
| 1048 | } |
| 1049 | |
| 1050 | BENCHMARK(BM_ListComprehension)->Range(1, 1 << 16); |
| 1051 |
nothing calls this directly
no test coverage detected