Class CorpusLoader
java.lang.Object
org.antlr.v4.test.runtime.java.api.perf.jmh.CorpusLoader
Loads the ANTLR Java runtime sources that are already packaged as
resources of
antlr4-perf-testsuite (see ../runtime resource
directory in the module POM). The corpus approximates multi-file language
front-end workloads (e.g. Groovy serial/parallel compilation).-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringResource root of the Java runtime sources inside the test classpath. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List<CorpusLoader.SourceFile>loadAcceptedOrSynthetic(int maxFiles, int minAccepted) Prefer real runtime sources that the bundled grammar accepts; if fewer thanminAcceptedsurvive, fall back to a synthetic corpus ofmaxFilesunits so A/B runs remain comparable.private static List<CorpusLoader.SourceFile>loadAllUnder(String rootResource, String suffix) static CorpusLoader.SourceFileloadLargest(String relativeUnderRuntimeSrc) static CorpusLoader.SourceFileLoad a single well-known large file used by the historical lexer bench.static List<CorpusLoader.SourceFile>Load every.javafile under the packaged runtime sources.static List<CorpusLoader.SourceFile>loadRuntimeJavaSources(int maxFiles) Load up tomaxFileslargest runtime.javasources (stable tie-break by path).private static StringreadResource(String resource) static List<CorpusLoader.SourceFile>syntheticJava7Corpus(int fileCount, int methodsPerFile) Build a deterministic synthetic Java 1.7-shaped corpus that the bundledJava.g4accepts fully.static inttotalChars(List<CorpusLoader.SourceFile> files) private static void
-
Field Details
-
RUNTIME_SRC_ROOT
Resource root of the Java runtime sources inside the test classpath.- See Also:
-
-
Constructor Details
-
CorpusLoader
private CorpusLoader()
-
-
Method Details
-
loadRuntimeJavaSources
Load every.javafile under the packaged runtime sources. Results are sorted by path for stable iteration order across runs.- Throws:
IOException
-
loadRuntimeJavaSources
Load up tomaxFileslargest runtime.javasources (stable tie-break by path). Useful for keeping JMH iterations bounded.- Throws:
IOException
-
loadParserJava
Load a single well-known large file used by the historical lexer bench.- Throws:
IOException
-
loadLargest
public static CorpusLoader.SourceFile loadLargest(String relativeUnderRuntimeSrc) throws IOException - Throws:
IOException
-
totalChars
-
syntheticJava7Corpus
Build a deterministic synthetic Java 1.7-shaped corpus that the bundledJava.g4accepts fully. Sized to stress lexer/parser without depending on real-world language level drift in runtime sources.- Parameters:
fileCount- number of compilation unitsmethodsPerFile- methods per class (drives expression/statement load)
-
loadAcceptedOrSynthetic
public static List<CorpusLoader.SourceFile> loadAcceptedOrSynthetic(int maxFiles, int minAccepted) throws IOException Prefer real runtime sources that the bundled grammar accepts; if fewer thanminAcceptedsurvive, fall back to a synthetic corpus ofmaxFilesunits so A/B runs remain comparable.- Throws:
IOException
-
loadAllUnder
private static List<CorpusLoader.SourceFile> loadAllUnder(String rootResource, String suffix) throws IOException - Throws:
IOException
-
walk
private static void walk(Path root, Path start, String suffix, List<CorpusLoader.SourceFile> out) throws IOException - Throws:
IOException
-
readResource
- Throws:
IOException
-