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

Function BM_AllocateError

eval/tests/allocation_benchmark_test.cc:122–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120BENCHMARK(BM_AllocateString);
121
122static 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}
143BENCHMARK(BM_AllocateError);
144
145static void BM_AllocateMap(benchmark::State& state) {

Callers

nothing calls this directly

Calls 4

RegisterBuiltinFunctionsFunction · 0.85
GetRegistryMethod · 0.80
GetValueMethod · 0.45

Tested by

no test coverage detected