| 191 | BENCHMARK(BM_AllocateMessage); |
| 192 | |
| 193 | static void BM_AllocateLargeMessage(benchmark::State& state) { |
| 194 | // Make sure attribute context is loaded in the generated descriptor pool. |
| 195 | rpc::context::AttributeContext context; |
| 196 | static_cast<void>(context); |
| 197 | |
| 198 | google::protobuf::Arena arena; |
| 199 | std::string expr(R"( |
| 200 | google.rpc.context.AttributeContext{ |
| 201 | source: google.rpc.context.AttributeContext.Peer{ |
| 202 | ip: '192.168.0.1', |
| 203 | port: 1025, |
| 204 | labels: {"abc": "123", "def": "456"} |
| 205 | }, |
| 206 | request: google.rpc.context.AttributeContext.Request{ |
| 207 | method: 'GET', |
| 208 | path: 'root', |
| 209 | host: 'www.example.com' |
| 210 | }, |
| 211 | resource: google.rpc.context.AttributeContext.Resource{ |
| 212 | labels: {"abc": "123", "def": "456"}, |
| 213 | } |
| 214 | })"); |
| 215 | auto builder = CreateCelExpressionBuilder(); |
| 216 | ASSERT_OK(RegisterBuiltinFunctions(builder->GetRegistry())); |
| 217 | |
| 218 | ASSERT_OK_AND_ASSIGN(ParsedExpr parsed_expr, Parse(expr)); |
| 219 | ASSERT_OK_AND_ASSIGN(auto cel_expr, |
| 220 | builder->CreateExpression(&parsed_expr.expr(), |
| 221 | &parsed_expr.source_info())); |
| 222 | |
| 223 | for (auto _ : state) { |
| 224 | Activation activation; |
| 225 | ASSERT_OK_AND_ASSIGN(CelValue result, |
| 226 | cel_expr->Evaluate(activation, &arena)); |
| 227 | ASSERT_TRUE(result.IsMessage()); |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | BENCHMARK(BM_AllocateLargeMessage); |
| 232 |
nothing calls this directly
no test coverage detected