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

Function RunBenchmark

extensions/bindings_ext_benchmark_test.cc:178–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176}
177
178void RunBenchmark(const BenchmarkCase& benchmark, benchmark::State& state) {
179 std::vector<Macro> all_macros = Macro::AllMacros();
180 std::vector<Macro> bindings_macros = cel::extensions::bindings_macros();
181 all_macros.insert(all_macros.end(), bindings_macros.begin(),
182 bindings_macros.end());
183 ASSERT_OK_AND_ASSIGN(
184 auto expr, ParseWithMacros(benchmark.expression, all_macros, "<input>"));
185
186 InterpreterOptions options;
187 auto builder =
188 google::api::expr::runtime::CreateCelExpressionBuilder(options);
189
190 ASSERT_OK(google::api::expr::runtime::RegisterBuiltinFunctions(
191 builder->GetRegistry()));
192
193 ASSERT_OK_AND_ASSIGN(auto program, builder->CreateExpression(
194 &expr.expr(), &expr.source_info()));
195
196 Activation activation;
197 google::protobuf::Arena arena;
198 for (auto _ : state) {
199 auto result = program->Evaluate(activation, &arena);
200 benchmark::DoNotOptimize(result);
201 ABSL_DCHECK_OK(result);
202 ABSL_DCHECK(benchmark.matcher.Matches(*result));
203 }
204}
205
206void BM_Simple(benchmark::State& state) {
207 RunBenchmark(BenchmarkCases()[0], state);

Callers 10

BM_SimpleFunction · 0.70
BM_MultipleReferencesFunction · 0.70
BM_NestedFunction · 0.70
BM_NestedDefinitionFunction · 0.70
BM_BindOusideLoopFunction · 0.70
BM_BindInsideLoopFunction · 0.70
BM_BindLoopBindFunction · 0.70
BM_TernaryDependsOnBindFunction · 0.70
BM_TwiceNestedDefinitionFunction · 0.70

Calls 8

AllMacrosFunction · 0.85
bindings_macrosFunction · 0.85
RegisterBuiltinFunctionsFunction · 0.85
GetRegistryMethod · 0.80
endMethod · 0.45
beginMethod · 0.45
EvaluateMethod · 0.45

Tested by

no test coverage detected