From 634a349678c66d6df7b450e3ae69f40a9146dcd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Thu, 21 May 2020 11:03:59 +0200 Subject: [PATCH] Simplify benchmark keys --- pmd-core/src/main/java/net/sourceforge/pmd/RuleSets.java | 8 +++++++- .../java/net/sourceforge/pmd/SourceCodeProcessor.java | 6 +----- .../sourceforge/pmd/benchmark/TimedOperationCategory.java | 7 ++----- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSets.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSets.java index 305dbd8332..3d7d3f2b33 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSets.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSets.java @@ -13,6 +13,9 @@ import java.util.Iterator; import java.util.List; import java.util.Set; +import net.sourceforge.pmd.benchmark.TimeTracker; +import net.sourceforge.pmd.benchmark.TimedOperation; +import net.sourceforge.pmd.benchmark.TimedOperationCategory; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.internal.RuleApplicator; @@ -128,7 +131,10 @@ public class RuleSets { this.ruleApplicator = prepareApplicator(); } - ruleApplicator.index(acuList); + try (TimedOperation to = TimeTracker.startOperation(TimedOperationCategory.RULE_AST_INDEXATION)) { + ruleApplicator.index(acuList); + } + for (RuleSet ruleSet : ruleSets) { if (ruleSet.applies(ctx.getSourceCodeFile())) { ruleApplicator.apply(ruleSet.getRules(), ctx); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/SourceCodeProcessor.java b/pmd-core/src/main/java/net/sourceforge/pmd/SourceCodeProcessor.java index 07829811ec..28b6d8b090 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/SourceCodeProcessor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/SourceCodeProcessor.java @@ -9,7 +9,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.util.Collections; -import java.util.List; import net.sourceforge.pmd.benchmark.TimeTracker; import net.sourceforge.pmd.benchmark.TimedOperation; @@ -163,10 +162,7 @@ public class SourceCodeProcessor { dependencyHelper.runLanguageSpecificStages(ruleSets, languageVersion, rootNode); - List acus = Collections.singletonList(rootNode); - try (TimedOperation to = TimeTracker.startOperation(TimedOperationCategory.RULE_APP)) { - ruleSets.apply(acus, ctx); - } + ruleSets.apply(Collections.singletonList(rootNode), ctx); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimedOperationCategory.java b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimedOperationCategory.java index 7a59502f09..7316e7664b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimedOperationCategory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimedOperationCategory.java @@ -16,17 +16,14 @@ import org.apache.commons.lang3.StringUtils; * @author Juan Martín Sotuyo Dodero */ public enum TimedOperationCategory { - /** Single rule execution. */ + /** Rule execution proper. */ RULE, - RULECHAIN_RULE, - /** Aggregate category for all rule application. */ - RULE_APP, COLLECT_FILES, LOAD_RULES, PARSER, /** Subdivided into one label for each stage. */ LANGUAGE_SPECIFIC_PROCESSING, - RULECHAIN_AST_INDEXATION, + RULE_AST_INDEXATION, REPORTING, FILE_PROCESSING, UNACCOUNTED;