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

Function BM_ExistsComprehensionBestCase

eval/tests/modern_benchmark_test.cc:1087–1113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1085BENCHMARK(BM_ListComprehension_Trace)->Range(1, 1 << 16);
1086
1087void BM_ExistsComprehensionBestCase(benchmark::State& state) {
1088 ASSERT_OK_AND_ASSIGN(ParsedExpr parsed_expr,
1089 Parse("my_int_list.exists(x, x == 1)"));
1090
1091 RuntimeOptions options = GetOptions();
1092 auto runtime = StandardRuntimeOrDie(options);
1093
1094 ASSERT_OK_AND_ASSIGN(auto cel_expr, ProtobufRuntimeAdapter::CreateProgram(
1095 *runtime, parsed_expr));
1096
1097 google::protobuf::Arena arena;
1098 Activation activation;
1099
1100 auto list_builder = cel::NewListValueBuilder(&arena);
1101
1102 ASSERT_THAT(list_builder->Add(IntValue(1)), IsOk());
1103
1104 activation.InsertOrAssignValue("my_int_list",
1105 std::move(*list_builder).Build());
1106
1107 for (auto _ : state) {
1108 ASSERT_OK_AND_ASSIGN(cel::Value result,
1109 cel_expr->Evaluate(&arena, activation));
1110 ASSERT_TRUE(result.IsBool());
1111 ASSERT_TRUE(result.GetBool().NativeValue());
1112 }
1113}
1114
1115BENCHMARK(BM_ExistsComprehensionBestCase);
1116

Callers

nothing calls this directly

Calls 9

GetOptionsFunction · 0.85
StandardRuntimeOrDieFunction · 0.85
InsertOrAssignValueMethod · 0.80
IntValueClass · 0.50
AddMethod · 0.45
BuildMethod · 0.45
IsBoolMethod · 0.45
NativeValueMethod · 0.45
GetBoolMethod · 0.45

Tested by

no test coverage detected