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

Function RunIdentBenchmark

eval/public/equality_function_registrar_test.cc:874–893  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

872}
873
874void RunIdentBenchmark(const CelValue& lhs, const CelValue& rhs,
875 benchmark::State& benchmark) {
876 InterpreterOptions opts;
877 auto builder = CreateCelExpressionBuilder(opts);
878 ASSERT_THAT(RegisterEqualityFunctions(builder->GetRegistry(), opts), IsOk());
879 ASSERT_OK_AND_ASSIGN(ParsedExpr parsed_expr, parser::Parse("lhs == rhs"));
880 google::protobuf::Arena arena;
881 Activation activation;
882 activation.InsertValue("lhs", lhs);
883 activation.InsertValue("rhs", rhs);
884
885 ASSERT_OK_AND_ASSIGN(auto plan,
886 builder->CreateExpression(&parsed_expr.expr(),
887 &parsed_expr.source_info()));
888
889 for (auto _ : benchmark) {
890 ASSERT_OK_AND_ASSIGN(auto result, plan->Evaluate(activation, &arena));
891 ASSERT_TRUE(result.IsBool());
892 }
893}
894
895void BM_EqualsInt(benchmark::State& s) { RunBenchmark("42 == 43", s); }
896

Callers 1

BM_EqualsBoundLegacyListFunction · 0.85

Calls 5

GetRegistryMethod · 0.80
InsertValueMethod · 0.80
IsBoolMethod · 0.45

Tested by

no test coverage detected