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

Function BM_ExistsComprehensionWorstCase

eval/tests/modern_benchmark_test.cc:1117–1147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1115BENCHMARK(BM_ExistsComprehensionBestCase);
1116
1117void BM_ExistsComprehensionWorstCase(benchmark::State& state) {
1118 ASSERT_OK_AND_ASSIGN(ParsedExpr parsed_expr,
1119 Parse("my_int_list.exists(x, x == -1)"));
1120
1121 RuntimeOptions options = GetOptions();
1122 auto runtime = StandardRuntimeOrDie(options);
1123
1124 ASSERT_OK_AND_ASSIGN(auto cel_expr, ProtobufRuntimeAdapter::CreateProgram(
1125 *runtime, parsed_expr));
1126
1127 google::protobuf::Arena arena;
1128 Activation activation;
1129
1130 auto list_builder = cel::NewListValueBuilder(&arena);
1131 int len = state.range(0);
1132 list_builder->Reserve(len);
1133
1134 for (int i = 0; i < len; i++) {
1135 ASSERT_THAT(list_builder->Add(IntValue(i)), IsOk());
1136 }
1137
1138 activation.InsertOrAssignValue("my_int_list",
1139 std::move(*list_builder).Build());
1140
1141 for (auto _ : state) {
1142 ASSERT_OK_AND_ASSIGN(cel::Value result,
1143 cel_expr->Evaluate(&arena, activation));
1144 ASSERT_TRUE(result.IsBool());
1145 ASSERT_FALSE(result.GetBool().NativeValue());
1146 }
1147}
1148
1149BENCHMARK(BM_ExistsComprehensionWorstCase)->Range(1, 1 << 10);
1150

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected