Class ATNHotPathMicroBenchmark
java.lang.Object
org.antlr.v4.test.runtime.java.api.perf.ATNHotPathMicroBenchmark
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:
ATNConfig.hashCode()cache hit vs full MurmurHash recompute- Lexer ATN reach with retained vs fresh
OrderedATNConfigSet - SLL config iteration without intermediate
ArrayList
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidCompare cachedATNConfig.hashCode()against an equivalent uncached MurmurHash of the same fields.private static voidEnd-to-end lexer match throughput on a small ATN with DFA cleared each outer batch so ATN simulation / reach remains on the hot path.private static voidMeasure cost of clearing+reusing an OrderedATNConfigSet vs allocating a new one each time (models LexerATNSimulator.computeTargetState).private static voidModels SLL computeTargetState: index walk over ATNConfigSet vs copying into a new ArrayList first.private static ATNprivate static voidfillReach(OrderedATNConfigSet set, ATNConfig[] pool) private static voidlexAll(LexerATNSimulator sim, String text) static voidprivate static intuncachedHash(ATNConfig config)
-
Field Details
-
WARMUP
private static final int WARMUP- See Also:
-
ITERS
private static final int ITERS- See Also:
-
-
Constructor Details
-
ATNHotPathMicroBenchmark
public ATNHotPathMicroBenchmark()
-
-
Method Details
-
main
- Throws:
Exception
-
benchHashCodeCache
private static void benchHashCodeCache()Compare cachedATNConfig.hashCode()against an equivalent uncached MurmurHash of the same fields. -
uncachedHash
-
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
-
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
-
buildTinyLexerAtn
-