Class ATNHotPathMicroBenchmark

java.lang.Object
org.antlr.v4.test.runtime.java.api.perf.ATNHotPathMicroBenchmark

public final class ATNHotPathMicroBenchmark extends Object
Standalone micro-benchmark for ATN hot-path optimizations. Lives in the performance testsuite (not the runtime unit-test tree). Run with:
   mvn -pl perf-testsuite -DskipTests exec:java \
     -Dexec.mainClass=org.antlr.v4.test.runtime.java.api.perf.ATNHotPathMicroBenchmark
 
or directly from the IDE / java -cp ....

Reports nanosecond/op and relative speedups for:

  • Field Details

  • Constructor Details

    • ATNHotPathMicroBenchmark

      public ATNHotPathMicroBenchmark()
  • Method Details

    • main

      public static void main(String[] args) throws Exception
      Throws:
      Exception
    • benchHashCodeCache

      private static void benchHashCodeCache()
      Compare cached ATNConfig.hashCode() against an equivalent uncached MurmurHash of the same fields.
    • uncachedHash

      private static int uncachedHash(ATNConfig config)
    • benchLexerReachReuse

      private static void benchLexerReachReuse()
      Measure cost of clearing+reusing an OrderedATNConfigSet vs allocating a new one each time (models LexerATNSimulator.computeTargetState). Config objects are prebuilt so the measurement isolates set alloc/clear.
    • fillReach

      private static void fillReach(OrderedATNConfigSet set, ATNConfig[] pool)
    • benchSllConfigIteration

      private static void benchSllConfigIteration()
      Models SLL computeTargetState: index walk over ATNConfigSet vs copying into a new ArrayList first.
    • benchLexerMatchThroughput

      private static void benchLexerMatchThroughput()
      End-to-end lexer match throughput on a small ATN with DFA cleared each outer batch so ATN simulation / reach remains on the hot path.
    • lexAll

      private static void lexAll(LexerATNSimulator sim, String text)
    • buildTinyLexerAtn

      private static ATN buildTinyLexerAtn()