| 1115 | BENCHMARK(BM_ExistsComprehensionBestCase); |
| 1116 | |
| 1117 | void 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 | |
| 1149 | BENCHMARK(BM_ExistsComprehensionWorstCase)->Range(1, 1 << 10); |
| 1150 |
nothing calls this directly
no test coverage detected