@Test
	@Timeout(20)
	public void testExponentialInclude(@TempDir Path tempDir) {
		String tempDirPath = tempDir.toString();
		String grammarFormat =
			"parser grammar Level_%d_%d;\n" +
			"\n" +
			"%s import Level_%d_1, Level_%d_2;\n" +
			"\n" +
			"rule_%d_%d : EOF;\n";

		FileUtils.mkdir(tempDirPath);

		long startTime = System.nanoTime();

		int levels = 20;
		for (int level = 0; level < levels; level++) {
			String leafPrefix = level == levels - 1 ? "//" : "";
			String grammar1 = String.format(grammarFormat, level, 1, leafPrefix, level + 1, level + 1, level, 1);
			writeFile(tempDirPath, "Level_" + level + "_1.g4", grammar1);
			if (level > 0) {
				String grammar2 = String.format(grammarFormat, level, 2, leafPrefix, level + 1, level + 1, level, 1);
				writeFile(tempDirPath, "Level_" + level + "_2.g4", grammar2);
			}
		}

		ErrorQueue equeue = Generator.antlrOnString(tempDirPath, "Java", "Level_0_1.g4", false);
		assertTrue(equeue.errors.isEmpty());

		long endTime = System.nanoTime();
		System.out.format("%s milliseconds.%n", (endTime - startTime) / 1000000.0);
	}
This method is separate from {@link #parse1} so the first pass can be distinguished when analyzing
 profiler results.
tool-testsuite/test/org/antlr/v4/test/tool/TestPerformance.java