From 5b214fc3d79705b572014657a9b9c28421dbf066 Mon Sep 17 00:00:00 2001 From: Keith Turner Date: Wed, 7 Jan 2026 16:41:55 +0000 Subject: [PATCH] Adds benchmark for creating parse trees Also updates comments in the benchmark that were incorrect. The comments were based on how the code used to work. --- .../tests/AccessExpressionBenchmark.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/core/src/test/java/org/apache/accumulo/access/tests/AccessExpressionBenchmark.java b/core/src/test/java/org/apache/accumulo/access/tests/AccessExpressionBenchmark.java index 64de076..b9706b2 100644 --- a/core/src/test/java/org/apache/accumulo/access/tests/AccessExpressionBenchmark.java +++ b/core/src/test/java/org/apache/accumulo/access/tests/AccessExpressionBenchmark.java @@ -31,6 +31,7 @@ import org.apache.accumulo.access.AccessEvaluator; import org.apache.accumulo.access.AccessExpression; import org.apache.accumulo.access.Authorizations; +import org.apache.accumulo.access.ParsedAccessExpression; import org.apache.accumulo.core.security.ColumnVisibility; import org.apache.accumulo.core.security.VisibilityEvaluator; import org.apache.accumulo.core.security.VisibilityParseException; @@ -163,7 +164,7 @@ List getVisibilityEvaluatorTests() { } /** - * Measures the time it takes to parse an expression stored in byte[] and produce a parse tree. + * Measures the time it takes to parse an expression stored in byte[] and validate it. */ @Benchmark public void measureBytesValidation(BenchmarkState state, Blackhole blackhole) { @@ -173,7 +174,7 @@ public void measureBytesValidation(BenchmarkState state, Blackhole blackhole) { } /** - * Measures the time it takes to parse an expression stored in a String and produce a parse tree. + * Measures the time it takes to parse an expression stored in a String and validate it. */ @Benchmark public void measureStringValidation(BenchmarkState state, Blackhole blackhole) { @@ -183,8 +184,18 @@ public void measureStringValidation(BenchmarkState state, Blackhole blackhole) { } /** - * Measures the time it takes to parse and evaluate an expression. This has to create the parse - * tree an operate on it. + * Measures the time it takes to parse an expression stored in a String and produce a parse tree. + * + */ + @Benchmark + public void measureCreateParseTree(BenchmarkState state, Blackhole blackhole) { + for (String accessExpression : state.getStringExpressions()) { + blackhole.consume(ParsedAccessExpression.parse(accessExpression)); + } + } + + /** + * Measures the time it takes to evaluate an expression. */ @Benchmark public void measureParseAndEvaluation(BenchmarkState state, Blackhole blackhole) {