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

Function BM_AllComprehensionWorstCase

eval/tests/modern_benchmark_test.cc:1181–1211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1179BENCHMARK(BM_AllComprehensionBestCase);
1180
1181void BM_AllComprehensionWorstCase(benchmark::State& state) {
1182 ASSERT_OK_AND_ASSIGN(ParsedExpr parsed_expr,
1183 Parse("my_int_list.all(x, x != -1)"));
1184
1185 RuntimeOptions options = GetOptions();
1186 auto runtime = StandardRuntimeOrDie(options);
1187
1188 ASSERT_OK_AND_ASSIGN(auto cel_expr, ProtobufRuntimeAdapter::CreateProgram(
1189 *runtime, parsed_expr));
1190
1191 google::protobuf::Arena arena;
1192 Activation activation;
1193
1194 auto list_builder = cel::NewListValueBuilder(&arena);
1195 int len = state.range(0);
1196 list_builder->Reserve(len);
1197
1198 for (int i = 0; i < len; i++) {
1199 ASSERT_THAT(list_builder->Add(IntValue(i)), IsOk());
1200 }
1201
1202 activation.InsertOrAssignValue("my_int_list",
1203 std::move(*list_builder).Build());
1204
1205 for (auto _ : state) {
1206 ASSERT_OK_AND_ASSIGN(cel::Value result,
1207 cel_expr->Evaluate(&arena, activation));
1208 ASSERT_TRUE(result.IsBool());
1209 ASSERT_TRUE(result.GetBool().NativeValue());
1210 }
1211}
1212
1213BENCHMARK(BM_AllComprehensionWorstCase)->Range(1, 1 << 10);
1214

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