Count full context transitions in statistics
This commit is contained in:
parent
0652b61a33
commit
af59f35481
|
@ -1260,6 +1260,7 @@ public class TestPerformance extends BaseTest {
|
||||||
public final int parserDFASize;
|
public final int parserDFASize;
|
||||||
public final long parserTotalTransitions;
|
public final long parserTotalTransitions;
|
||||||
public final long parserComputedTransitions;
|
public final long parserComputedTransitions;
|
||||||
|
public final long parserFullContextTransitions;
|
||||||
|
|
||||||
public FileParseResult(String sourceName, int checksum, @Nullable ParseTree parseTree, int tokenCount, long startTime, Lexer lexer, Parser parser) {
|
public FileParseResult(String sourceName, int checksum, @Nullable ParseTree parseTree, int tokenCount, long startTime, Lexer lexer, Parser parser) {
|
||||||
this.sourceName = sourceName;
|
this.sourceName = sourceName;
|
||||||
|
@ -1298,9 +1299,11 @@ public class TestPerformance extends BaseTest {
|
||||||
if (interpreter instanceof StatisticsParserATNSimulator) {
|
if (interpreter instanceof StatisticsParserATNSimulator) {
|
||||||
parserTotalTransitions = ((StatisticsParserATNSimulator)interpreter).totalTransitions;
|
parserTotalTransitions = ((StatisticsParserATNSimulator)interpreter).totalTransitions;
|
||||||
parserComputedTransitions = ((StatisticsParserATNSimulator)interpreter).computedTransitions;
|
parserComputedTransitions = ((StatisticsParserATNSimulator)interpreter).computedTransitions;
|
||||||
|
parserFullContextTransitions = ((StatisticsParserATNSimulator)interpreter).fullContextTransitions;
|
||||||
} else {
|
} else {
|
||||||
parserTotalTransitions = 0;
|
parserTotalTransitions = 0;
|
||||||
parserComputedTransitions = 0;
|
parserComputedTransitions = 0;
|
||||||
|
parserFullContextTransitions = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dfaSize = 0;
|
int dfaSize = 0;
|
||||||
|
@ -1315,6 +1318,7 @@ public class TestPerformance extends BaseTest {
|
||||||
parserDFASize = 0;
|
parserDFASize = 0;
|
||||||
parserTotalTransitions = 0;
|
parserTotalTransitions = 0;
|
||||||
parserComputedTransitions = 0;
|
parserComputedTransitions = 0;
|
||||||
|
parserFullContextTransitions = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1349,6 +1353,7 @@ public class TestPerformance extends BaseTest {
|
||||||
|
|
||||||
public long totalTransitions;
|
public long totalTransitions;
|
||||||
public long computedTransitions;
|
public long computedTransitions;
|
||||||
|
public long fullContextTransitions;
|
||||||
|
|
||||||
public StatisticsParserATNSimulator(ATN atn, DFA[] decisionToDFA, PredictionContextCache sharedContextCache) {
|
public StatisticsParserATNSimulator(ATN atn, DFA[] decisionToDFA, PredictionContextCache sharedContextCache) {
|
||||||
super(atn, decisionToDFA, sharedContextCache);
|
super(atn, decisionToDFA, sharedContextCache);
|
||||||
|
@ -1369,6 +1374,17 @@ public class TestPerformance extends BaseTest {
|
||||||
computedTransitions++;
|
computedTransitions++;
|
||||||
return super.computeTargetState(dfa, previousD, t);
|
return super.computeTargetState(dfa, previousD, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ATNConfigSet computeReachSet(ATNConfigSet closure, int t, boolean fullCtx) {
|
||||||
|
if (fullCtx) {
|
||||||
|
totalTransitions++;
|
||||||
|
computedTransitions++;
|
||||||
|
fullContextTransitions++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.computeReachSet(closure, t, fullCtx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class DescriptiveErrorListener extends BaseErrorListener {
|
private static class DescriptiveErrorListener extends BaseErrorListener {
|
||||||
|
|
Loading…
Reference in New Issue