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

Function BM_AllComprehensionBestCase

eval/tests/modern_benchmark_test.cc:1151–1177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1149BENCHMARK(BM_ExistsComprehensionWorstCase)->Range(1, 1 << 10);
1150
1151void BM_AllComprehensionBestCase(benchmark::State& state) {
1152 ASSERT_OK_AND_ASSIGN(ParsedExpr parsed_expr,
1153 Parse("my_int_list.exists(x, x != 1)"));
1154
1155 RuntimeOptions options = GetOptions();
1156 auto runtime = StandardRuntimeOrDie(options);
1157
1158 ASSERT_OK_AND_ASSIGN(auto cel_expr, ProtobufRuntimeAdapter::CreateProgram(
1159 *runtime, parsed_expr));
1160
1161 google::protobuf::Arena arena;
1162 Activation activation;
1163
1164 auto list_builder = cel::NewListValueBuilder(&arena);
1165
1166 ASSERT_THAT(list_builder->Add(IntValue(1)), IsOk());
1167
1168 activation.InsertOrAssignValue("my_int_list",
1169 std::move(*list_builder).Build());
1170
1171 for (auto _ : state) {
1172 ASSERT_OK_AND_ASSIGN(cel::Value result,
1173 cel_expr->Evaluate(&arena, activation));
1174 ASSERT_TRUE(result.IsBool());
1175 ASSERT_FALSE(result.GetBool().NativeValue());
1176 }
1177}
1178
1179BENCHMARK(BM_AllComprehensionBestCase);
1180

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