| 588 | BENCHMARK(BM_Comprehension)->Range(1, 1 << 20); |
| 589 | |
| 590 | void BM_Comprehension_Trace(benchmark::State& state) { |
| 591 | RuntimeOptions options = GetOptions(); |
| 592 | options.enable_recursive_tracing = true; |
| 593 | |
| 594 | options.comprehension_max_iterations = 10000000; |
| 595 | auto runtime = StandardRuntimeOrDie(options); |
| 596 | google::protobuf::Arena arena; |
| 597 | Expr expr; |
| 598 | Activation activation; |
| 599 | ASSERT_TRUE(google::protobuf::TextFormat::ParseFromString(kListSum, &expr)); |
| 600 | |
| 601 | ASSERT_OK_AND_ASSIGN(auto cel_expr, |
| 602 | ProtobufRuntimeAdapter::CreateProgram(*runtime, expr)); |
| 603 | |
| 604 | auto list_builder = cel::NewListValueBuilder(&arena); |
| 605 | |
| 606 | int len = state.range(0); |
| 607 | list_builder->Reserve(len); |
| 608 | for (int i = 0; i < len; i++) { |
| 609 | ASSERT_THAT(list_builder->Add(IntValue(1)), IsOk()); |
| 610 | } |
| 611 | activation.InsertOrAssignValue("list_var", std::move(*list_builder).Build()); |
| 612 | |
| 613 | for (auto _ : state) { |
| 614 | ASSERT_OK_AND_ASSIGN(cel::Value result, |
| 615 | cel_expr->Trace(&arena, activation, EmptyCallback)); |
| 616 | ASSERT_TRUE(InstanceOf<IntValue>(result)); |
| 617 | ASSERT_EQ(Cast<IntValue>(result), len); |
| 618 | } |
| 619 | } |
| 620 | |
| 621 | BENCHMARK(BM_Comprehension_Trace)->Range(1, 1 << 20); |
| 622 |
nothing calls this directly
no test coverage detected