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

Function BM_AllocateMessage

eval/tests/allocation_benchmark_test.cc:166–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164BENCHMARK(BM_AllocateMap);
165
166static void BM_AllocateMessage(benchmark::State& state) {
167 google::protobuf::Arena arena;
168 std::string expr(
169 "google.api.expr.runtime.RequestContext{"
170 "ip: '192.168.0.1',"
171 "path: '/root'}");
172 // Make sure RequestContext is loaded in the generated descriptor pool.
173 RequestContext context;
174 static_cast<void>(context);
175 auto builder = CreateCelExpressionBuilder();
176 ASSERT_OK(RegisterBuiltinFunctions(builder->GetRegistry()));
177
178 ASSERT_OK_AND_ASSIGN(ParsedExpr parsed_expr, Parse(expr));
179 ASSERT_OK_AND_ASSIGN(auto cel_expr,
180 builder->CreateExpression(&parsed_expr.expr(),
181 &parsed_expr.source_info()));
182
183 for (auto _ : state) {
184 Activation activation;
185 ASSERT_OK_AND_ASSIGN(CelValue result,
186 cel_expr->Evaluate(activation, &arena));
187 ASSERT_TRUE(result.IsMessage());
188 }
189}
190
191BENCHMARK(BM_AllocateMessage);
192

Callers

nothing calls this directly

Calls 4

RegisterBuiltinFunctionsFunction · 0.85
GetRegistryMethod · 0.80
IsMessageMethod · 0.45

Tested by

no test coverage detected