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

Function BM_NestedComprehension_Trace

eval/tests/modern_benchmark_test.cc:981–1014  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

979BENCHMARK(BM_NestedComprehension)->Range(1, 1 << 10);
980
981void 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
1016BENCHMARK(BM_NestedComprehension_Trace)->Range(1, 1 << 10);
1017

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