rajat315315 commented on code in PR #16361:
URL: https://github.com/apache/lucene/pull/16361#discussion_r3610018565
##########
lucene/benchmark-jmh/src/java/org/apache/lucene/benchmark/jmh/CompiledAutomatonBenchmark.java:
##########
@@ -0,0 +1,64 @@
+package org.apache.lucene.benchmark.jmh;
+
+import java.io.IOException;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.BytesRefBuilder;
+import org.apache.lucene.util.automaton.Automaton;
+import org.apache.lucene.util.automaton.CompiledAutomaton;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.Warmup;
+
+@Fork(1)
+@Warmup(iterations = 3, time = 2)
+@Measurement(iterations = 5, time = 2)
+@BenchmarkMode(Mode.Throughput)
+@OutputTimeUnit(TimeUnit.MILLISECONDS)
+@State(Scope.Benchmark)
+public class CompiledAutomatonBenchmark {
+
+ private CompiledAutomaton compiled;
+ private BytesRef[] inputs;
+ private BytesRefBuilder output;
+ private int index;
+
+ @Setup
+ public void setup() throws IOException {
+ Automaton.Builder builder = new Automaton.Builder();
+ int state0 = builder.createState();
+ int destState = builder.createState();
+ builder.setAccept(destState, true);
+ // Add 120 transitions to state 0 with sorted labels
+ for (int i = 0; i < 120; i++) {
+ builder.addTransition(state0, destState, i * 2, i * 2);
+ }
Review Comment:
Thanks, I have added the case where I am giving input as random odd labels
so that it will always trigger `addTail()`.
Below I am attaching the results gathered.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]