| 120 | BENCHMARK(BM_AllocateString); |
| 121 | |
| 122 | static void BM_AllocateError(benchmark::State& state) { |
| 123 | google::protobuf::Arena arena; |
| 124 | std::string expr("1 / 0"); |
| 125 | auto builder = CreateCelExpressionBuilder(); |
| 126 | ASSERT_OK(RegisterBuiltinFunctions(builder->GetRegistry())); |
| 127 | |
| 128 | ASSERT_OK_AND_ASSIGN(ParsedExpr parsed_expr, Parse(expr)); |
| 129 | ASSERT_OK_AND_ASSIGN(auto cel_expr, |
| 130 | builder->CreateExpression(&parsed_expr.expr(), |
| 131 | &parsed_expr.source_info())); |
| 132 | |
| 133 | for (auto _ : state) { |
| 134 | Activation activation; |
| 135 | ASSERT_OK_AND_ASSIGN(CelValue result, |
| 136 | cel_expr->Evaluate(activation, &arena)); |
| 137 | const CelError* value; |
| 138 | ASSERT_TRUE(result.GetValue(&value)); |
| 139 | ASSERT_THAT(*value, StatusIs(absl::StatusCode::kInvalidArgument, |
| 140 | HasSubstr("divide by zero"))); |
| 141 | } |
| 142 | } |
| 143 | BENCHMARK(BM_AllocateError); |
| 144 | |
| 145 | static void BM_AllocateMap(benchmark::State& state) { |
nothing calls this directly
no test coverage detected