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

Function BM_HasProtoMap

eval/tests/modern_benchmark_test.cc:680–703  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

678BENCHMARK(BM_HasProto);
679
680void BM_HasProtoMap(benchmark::State& state) {
681 RuntimeOptions options = GetOptions();
682 auto runtime = StandardRuntimeOrDie(options);
683
684 ASSERT_OK_AND_ASSIGN(ParsedExpr parsed_expr,
685 Parse("has(request.headers.create_time) && "
686 "!has(request.headers.update_time)"));
687 ASSERT_OK_AND_ASSIGN(auto cel_expr, ProtobufRuntimeAdapter::CreateProgram(
688 *runtime, parsed_expr));
689
690 google::protobuf::Arena arena;
691 Activation activation;
692
693 RequestContext request;
694 request.mutable_headers()->insert({"create_time", "2021-01-01"});
695 activation.InsertOrAssignValue("request", WrapMessageOrDie(request, &arena));
696
697 for (auto _ : state) {
698 ASSERT_OK_AND_ASSIGN(cel::Value result,
699 cel_expr->Evaluate(&arena, activation));
700 ASSERT_TRUE(InstanceOf<BoolValue>(result) &&
701 Cast<BoolValue>(result).NativeValue());
702 }
703}
704
705BENCHMARK(BM_HasProtoMap);
706

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