| 979 | BENCHMARK(BM_NestedComprehension)->Range(1, 1 << 10); |
| 980 | |
| 981 | void BM_NestedComprehension_Trace(benchmark::State& state) { |
| 982 | Expr expr; |
| 983 | ASSERT_TRUE(google::protobuf::TextFormat::ParseFromString(kNestedListSum, &expr)); |
| 984 | |
| 985 | RuntimeOptions options = GetOptions(); |
| 986 | options.comprehension_max_iterations = 10000000; |
| 987 | options.enable_comprehension_list_append = true; |
| 988 | options.enable_recursive_tracing = true; |
| 989 | |
| 990 | auto runtime = StandardRuntimeOrDie(options); |
| 991 | |
| 992 | google::protobuf::Arena arena; |
| 993 | Activation activation; |
| 994 | |
| 995 | auto list_builder = cel::NewListValueBuilder(&arena); |
| 996 | |
| 997 | int len = state.range(0); |
| 998 | list_builder->Reserve(len); |
| 999 | for (int i = 0; i < len; i++) { |
| 1000 | ASSERT_THAT(list_builder->Add(IntValue(1)), IsOk()); |
| 1001 | } |
| 1002 | |
| 1003 | activation.InsertOrAssignValue("list_var", std::move(*list_builder).Build()); |
| 1004 | |
| 1005 | ASSERT_OK_AND_ASSIGN(auto cel_expr, |
| 1006 | ProtobufRuntimeAdapter::CreateProgram(*runtime, expr)); |
| 1007 | |
| 1008 | for (auto _ : state) { |
| 1009 | ASSERT_OK_AND_ASSIGN(cel::Value result, |
| 1010 | cel_expr->Trace(&arena, activation, &EmptyCallback)); |
| 1011 | ASSERT_TRUE(InstanceOf<IntValue>(result)); |
| 1012 | ASSERT_EQ(Cast<IntValue>(result), len * len); |
| 1013 | } |
| 1014 | } |
| 1015 | |
| 1016 | BENCHMARK(BM_NestedComprehension_Trace)->Range(1, 1 << 10); |
| 1017 |
nothing calls this directly
no test coverage detected