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

Function BM_HasMap

eval/tests/modern_benchmark_test.cc:623–649  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

621BENCHMARK(BM_Comprehension_Trace)->Range(1, 1 << 20);
622
623void BM_HasMap(benchmark::State& state) {
624 google::protobuf::Arena arena;
625 Activation activation;
626 ASSERT_OK_AND_ASSIGN(ParsedExpr parsed_expr,
627 Parse("has(request.path) && !has(request.ip)"));
628
629 RuntimeOptions options = GetOptions();
630 auto runtime = StandardRuntimeOrDie(options);
631
632 ASSERT_OK_AND_ASSIGN(auto cel_expr, ProtobufRuntimeAdapter::CreateProgram(
633 *runtime, parsed_expr));
634
635 auto map_builder = cel::NewMapValueBuilder(&arena);
636
637 ASSERT_THAT(
638 map_builder->Put(cel::StringValue("path"), cel::StringValue("path")),
639 IsOk());
640
641 activation.InsertOrAssignValue("request", std::move(*map_builder).Build());
642
643 for (auto _ : state) {
644 ASSERT_OK_AND_ASSIGN(cel::Value result,
645 cel_expr->Evaluate(&arena, activation));
646 ASSERT_TRUE(InstanceOf<BoolValue>(result) &&
647 Cast<BoolValue>(result).NativeValue());
648 }
649}
650
651BENCHMARK(BM_HasMap);
652

Callers

nothing calls this directly

Calls 7

GetOptionsFunction · 0.85
StandardRuntimeOrDieFunction · 0.85
InsertOrAssignValueMethod · 0.80
StringValueClass · 0.50
PutMethod · 0.45
BuildMethod · 0.45
NativeValueMethod · 0.45

Tested by

no test coverage detected