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

Function BM_HasProto

eval/tests/modern_benchmark_test.cc:653–676  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

651BENCHMARK(BM_HasMap);
652
653void BM_HasProto(benchmark::State& state) {
654 RuntimeOptions options = GetOptions();
655 auto runtime = StandardRuntimeOrDie(options);
656
657 ASSERT_OK_AND_ASSIGN(ParsedExpr parsed_expr,
658 Parse("has(request.path) && !has(request.ip)"));
659 ASSERT_OK_AND_ASSIGN(auto cel_expr, ProtobufRuntimeAdapter::CreateProgram(
660 *runtime, parsed_expr));
661
662 google::protobuf::Arena arena;
663 Activation activation;
664
665 RequestContext request;
666 request.set_path(kPath);
667 request.set_token(kToken);
668 activation.InsertOrAssignValue("request", WrapMessageOrDie(request, &arena));
669
670 for (auto _ : state) {
671 ASSERT_OK_AND_ASSIGN(cel::Value result,
672 cel_expr->Evaluate(&arena, activation));
673 ASSERT_TRUE(InstanceOf<BoolValue>(result) &&
674 Cast<BoolValue>(result).NativeValue());
675 }
676}
677
678BENCHMARK(BM_HasProto);
679

Callers

nothing calls this directly

Calls 5

GetOptionsFunction · 0.85
StandardRuntimeOrDieFunction · 0.85
WrapMessageOrDieFunction · 0.85
InsertOrAssignValueMethod · 0.80
NativeValueMethod · 0.45

Tested by

no test coverage detected