MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / BM_Comprehension_Trace

Function BM_Comprehension_Trace

eval/tests/modern_benchmark_test.cc:590–619  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

588BENCHMARK(BM_Comprehension)->Range(1, 1 << 20);
589
590void 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
621BENCHMARK(BM_Comprehension_Trace)->Range(1, 1 << 20);
622

Callers

nothing calls this directly

Calls 7

GetOptionsFunction · 0.85
StandardRuntimeOrDieFunction · 0.85
InsertOrAssignValueMethod · 0.80
IntValueClass · 0.50
ReserveMethod · 0.45
AddMethod · 0.45
BuildMethod · 0.45

Tested by

no test coverage detected