From 646f673d841f13614f948131592e4847b0943d18 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Tue, 30 Apr 2013 21:35:10 -0500 Subject: [PATCH] Track token count separately for each pass --- tool/test/org/antlr/v4/test/TestPerformance.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tool/test/org/antlr/v4/test/TestPerformance.java b/tool/test/org/antlr/v4/test/TestPerformance.java index 1040759fe..facd8d2a3 100644 --- a/tool/test/org/antlr/v4/test/TestPerformance.java +++ b/tool/test/org/antlr/v4/test/TestPerformance.java @@ -97,6 +97,7 @@ import java.util.concurrent.Future; import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicIntegerArray; import java.util.logging.Level; import java.util.logging.Logger; import java.util.zip.CRC32; @@ -302,7 +303,7 @@ public class TestPerformance extends BaseTest { private static final ParseTreeListener[] sharedListeners = new ParseTreeListener[NUMBER_OF_THREADS]; - private final AtomicInteger tokenCount = new AtomicInteger(); + private final AtomicIntegerArray tokenCount = new AtomicIntegerArray(PASSES); private int currentPass; @Test @@ -475,7 +476,7 @@ public class TestPerformance extends BaseTest { @SuppressWarnings("unused") protected void parseSources(final ParserFactory factory, Collection sources) throws InterruptedException { long startTime = System.currentTimeMillis(); - tokenCount.set(0); + tokenCount.set(currentPass, 0); int inputSize = 0; int inputCount = 0; @@ -531,7 +532,7 @@ public class TestPerformance extends BaseTest { System.out.format("Total parse time for %d files (%d KB, %d tokens, checksum 0x%8X): %dms%n", inputCount, inputSize / 1024, - tokenCount.get(), + tokenCount.get(currentPass), COMPUTE_CHECKSUM ? checksum.getValue() : 0, System.currentTimeMillis() - startTime); @@ -769,7 +770,7 @@ public class TestPerformance extends BaseTest { CommonTokenStream tokens = new CommonTokenStream(lexer); tokens.fill(); - tokenCount.addAndGet(tokens.size()); + tokenCount.addAndGet(currentPass, tokens.size()); if (COMPUTE_CHECKSUM) { for (Token token : tokens.getTokens()) {