| 1179 | BENCHMARK(BM_AllComprehensionBestCase); |
| 1180 | |
| 1181 | void 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 | |
| 1213 | BENCHMARK(BM_AllComprehensionWorstCase)->Range(1, 1 << 10); |
| 1214 |
nothing calls this directly
no test coverage detected