Skip to content
Snippets Groups Projects
Commit 39ff459b authored by Reiner Jung's avatar Reiner Jung
Browse files

Merge branch 'ignore-missing-statistics' into 'main'

Updated ignore feature to select specific metrics/statistics.

See merge request oceandsl/oceandsl-tools!50
parents d928da88 84610bcf
Branches
No related tags found
No related merge requests found
/***************************************************************************
* Copyright (C) 2023 OceanDSL (https://oceandsl.uni-kiel.de)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
package org.oceandsl.tools.mvis;
/**
* Parameter enumeration of the available statistics.
*
* @author Reiner Jung
* @since 1.3.0
*/
public enum EStatistics {
ALLEN, NUM_OF_CALLS, OP_COUPLING, MODULE_COUPLING
}
...@@ -17,6 +17,7 @@ package org.oceandsl.tools.mvis; ...@@ -17,6 +17,7 @@ package org.oceandsl.tools.mvis;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.List; import java.util.List;
import java.util.Set;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;
import com.beust.jcommander.converters.PathConverter; import com.beust.jcommander.converters.PathConverter;
...@@ -52,8 +53,9 @@ public class Settings { // NOPMD ...@@ -52,8 +53,9 @@ public class Settings { // NOPMD
"--graphs" }, required = false, variableArity = true, converter = GraphTypeConverter.class, description = "Specify which output graphs must be generated") "--graphs" }, required = false, variableArity = true, converter = GraphTypeConverter.class, description = "Specify which output graphs must be generated")
private List<EOutputGraph> outputGraphs; private List<EOutputGraph> outputGraphs;
@Parameter(names = "--ignore-statistics", required = false, description = "When specified statistics are ignored.") @Parameter(names = { "-c",
private boolean ignoreStatistics; "--compute-statistics" }, variableArity = true, required = false, converter = StatisticsConverter.class, description = "Generate the listed statistics.")
private Set<EStatistics> computeStatistics;
@Parameter(names = { "-m", @Parameter(names = { "-m",
"--mode" }, required = true, variableArity = true, converter = GraphGenerationConverter.class, description = "Mode deciding whether an edge is added when its nodes are not selected") "--mode" }, required = true, variableArity = true, converter = GraphGenerationConverter.class, description = "Mode deciding whether an edge is added when its nodes are not selected")
...@@ -79,8 +81,8 @@ public class Settings { // NOPMD ...@@ -79,8 +81,8 @@ public class Settings { // NOPMD
return this.selector; return this.selector;
} }
public boolean isIgnoreStatistics() { public Set<EStatistics> getComputeStatistics() {
return this.ignoreStatistics; return this.computeStatistics;
} }
public EGraphGenerationMode getGraphGenerationMode() { public EGraphGenerationMode getGraphGenerationMode() {
... ...
......
/***************************************************************************
* Copyright (C) 2021 OceanDSL (https://oceandsl.uni-kiel.de)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
package org.oceandsl.tools.mvis;
import java.util.Locale;
import com.beust.jcommander.IStringConverter;
/**
* @author Reiner Jung
* @since 1.3
*
*/
public class StatisticsConverter implements IStringConverter<EStatistics> {
@Override
public EStatistics convert(final String value) {
for (final EStatistics outputGraph : EStatistics.values()) {
if (outputGraph.name().toLowerCase(Locale.ROOT).replace("_", "-").equals(value)) {
return outputGraph;
}
}
throw new IllegalArgumentException(String.format("Statistics %s is not supported.", value));
}
}
...@@ -75,8 +75,10 @@ public class TeetimeConfiguration extends Configuration { ...@@ -75,8 +75,10 @@ public class TeetimeConfiguration extends Configuration {
this.connectPorts(readerStage.getOutputPort(), statisticsDistributor.getInputPort()); this.connectPorts(readerStage.getOutputPort(), statisticsDistributor.getInputPort());
this.createStatisticsStages(settings, statisticsDistributor); this.createNumberOfCallsStatistics(settings, statisticsDistributor);
this.createAllenMetricStages(settings, statisticsDistributor); this.createOperationCouplingStatistics(settings, statisticsDistributor);
this.createModuleCouplingStatistics(settings, statisticsDistributor);
this.createAllenMetricStatistics(settings, statisticsDistributor);
final Distributor<ModelRepository> triggerDistributor = new Distributor<>(new CopyByReferenceStrategy()); final Distributor<ModelRepository> triggerDistributor = new Distributor<>(new CopyByReferenceStrategy());
...@@ -141,10 +143,9 @@ public class TeetimeConfiguration extends Configuration { ...@@ -141,10 +143,9 @@ public class TeetimeConfiguration extends Configuration {
} }
private void createStatisticsStages(final Settings settings, private void createNumberOfCallsStatistics(final Settings settings,
final Distributor<ModelRepository> statisticsDistributor) { final Distributor<ModelRepository> statisticsDistributor) {
/** compute statistics. */ if (settings.getComputeStatistics().contains(EStatistics.NUM_OF_CALLS)) {
if (!settings.isIgnoreStatistics()) {
final NumberOfCallsStage numberOfCallsStage = new NumberOfCallsStage(); final NumberOfCallsStage numberOfCallsStage = new NumberOfCallsStage();
final TableCSVSink operationCallSink = new TableCSVSink(settings.getOutputDirectory(), String final TableCSVSink operationCallSink = new TableCSVSink(settings.getOutputDirectory(), String
.format("%s-%s", settings.getSelector().getFilePrefix(), TeetimeConfiguration.OPERATION_CALLS_CSV)); .format("%s-%s", settings.getSelector().getFilePrefix(), TeetimeConfiguration.OPERATION_CALLS_CSV));
...@@ -152,42 +153,56 @@ public class TeetimeConfiguration extends Configuration { ...@@ -152,42 +153,56 @@ public class TeetimeConfiguration extends Configuration {
this.connectPorts(statisticsDistributor.getNewOutputPort(), numberOfCallsStage.getInputPort()); this.connectPorts(statisticsDistributor.getNewOutputPort(), numberOfCallsStage.getInputPort());
this.connectPorts(numberOfCallsStage.getOutputPort(), operationCallSink.getInputPort()); this.connectPorts(numberOfCallsStage.getOutputPort(), operationCallSink.getInputPort());
} }
}
private void createOperationCouplingStatistics(final Settings settings,
final Distributor<ModelRepository> statisticsDistributor) {
if (settings.getComputeStatistics().contains(EStatistics.OP_COUPLING)) {
final OperationCallGraphStage functionCallGraphStage = new OperationCallGraphStage(settings.getSelector(), final OperationCallGraphStage functionCallGraphStage = new OperationCallGraphStage(settings.getSelector(),
settings.getGraphGenerationMode()); settings.getGraphGenerationMode());
final OperationNodeCountCouplingStage functionNodeCouplingStage = new OperationNodeCountCouplingStage(); final OperationNodeCountCouplingStage functionNodeCouplingStage = new OperationNodeCountCouplingStage();
final TableCSVSink distinctOperationDegreeSink = new TableCSVSink(settings.getOutputDirectory(),
String.format("%s-%s", settings.getSelector().getFilePrefix(),
TeetimeConfiguration.DISTINCT_OPERATION_DEGREE_CSV));
this.connectPorts(statisticsDistributor.getNewOutputPort(), functionCallGraphStage.getInputPort());
this.connectPorts(functionCallGraphStage.getOutputPort(), functionNodeCouplingStage.getInputPort());
this.connectPorts(functionNodeCouplingStage.getOutputPort(), distinctOperationDegreeSink.getInputPort());
}
}
private void createModuleCouplingStatistics(final Settings settings,
final Distributor<ModelRepository> statisticsDistributor) {
if (settings.getComputeStatistics().contains(EStatistics.MODULE_COUPLING)) {
final ModuleCallGraphStage moduleCallGraphStage = new ModuleCallGraphStage(settings.getSelector(), final ModuleCallGraphStage moduleCallGraphStage = new ModuleCallGraphStage(settings.getSelector(),
settings.getGraphGenerationMode()); settings.getGraphGenerationMode());
final ModuleNodeCountCouplingStage moduleNodeCouplingStage = new ModuleNodeCountCouplingStage(); final ModuleNodeCountCouplingStage moduleNodeCouplingStage = new ModuleNodeCountCouplingStage();
/** Sinks for metrics writing to CSV files. */
final TableCSVSink distinctOperationDegreeSink = new TableCSVSink(settings.getOutputDirectory(), String.format(
"%s-%s", settings.getSelector().getFilePrefix(), TeetimeConfiguration.DISTINCT_OPERATION_DEGREE_CSV));
final TableCSVSink distinctModuleDegreeSink = new TableCSVSink(settings.getOutputDirectory(), String.format( final TableCSVSink distinctModuleDegreeSink = new TableCSVSink(settings.getOutputDirectory(), String.format(
"%s-%s", settings.getSelector().getFilePrefix(), TeetimeConfiguration.DISTINCT_MODULE_DEGREE_CSV)); "%s-%s", settings.getSelector().getFilePrefix(), TeetimeConfiguration.DISTINCT_MODULE_DEGREE_CSV));
this.connectPorts(statisticsDistributor.getNewOutputPort(), functionCallGraphStage.getInputPort());
this.connectPorts(functionCallGraphStage.getOutputPort(), functionNodeCouplingStage.getInputPort());
this.connectPorts(functionNodeCouplingStage.getOutputPort(), distinctOperationDegreeSink.getInputPort());
this.connectPorts(statisticsDistributor.getNewOutputPort(), moduleCallGraphStage.getInputPort()); this.connectPorts(statisticsDistributor.getNewOutputPort(), moduleCallGraphStage.getInputPort());
this.connectPorts(moduleCallGraphStage.getOutputPort(), moduleNodeCouplingStage.getInputPort()); this.connectPorts(moduleCallGraphStage.getOutputPort(), moduleNodeCouplingStage.getInputPort());
this.connectPorts(moduleNodeCouplingStage.getOutputPort(), distinctModuleDegreeSink.getInputPort()); this.connectPorts(moduleNodeCouplingStage.getOutputPort(), distinctModuleDegreeSink.getInputPort());
} }
}
private void createAllenMetricStages(final Settings settings, private void createAllenMetricStatistics(final Settings settings,
final Distributor<ModelRepository> statisticsDistributor) { final Distributor<ModelRepository> statisticsDistributor) {
/** setup allen metrics. */ if (settings.getComputeStatistics().contains(EStatistics.ALLEN)) {
final AllenDeployedArchitectureGraphStage allenArchitectureModularGraphStage = new AllenDeployedArchitectureGraphStage( final AllenDeployedArchitectureGraphStage allenArchitectureModularGraphStage = new AllenDeployedArchitectureGraphStage(
settings.getSelector(), settings.getGraphGenerationMode()); settings.getSelector(), settings.getGraphGenerationMode());
final ComputeAllenComplexityMetrics<DeployedComponent> computeAllenComplexityStage = new ComputeAllenComplexityMetrics<>( final ComputeAllenComplexityMetrics<DeployedComponent> computeAllenComplexityStage = new ComputeAllenComplexityMetrics<>(
new KiekerArchitectureModelSystemGraphUtils(), HyperGraphSize.class, Complexity.class, Coupling.class, new KiekerArchitectureModelSystemGraphUtils(), HyperGraphSize.class, Complexity.class,
Cohesion.class); Coupling.class, Cohesion.class);
final SaveAllenDataStage saveAllenDataStage = new SaveAllenDataStage(settings.getOutputDirectory()); final SaveAllenDataStage saveAllenDataStage = new SaveAllenDataStage(settings.getOutputDirectory());
this.connectPorts(statisticsDistributor.getNewOutputPort(), allenArchitectureModularGraphStage.getInputPort()); this.connectPorts(statisticsDistributor.getNewOutputPort(),
allenArchitectureModularGraphStage.getInputPort());
this.connectPorts(allenArchitectureModularGraphStage.getOutputPort(), this.connectPorts(allenArchitectureModularGraphStage.getOutputPort(),
computeAllenComplexityStage.getInputPort()); computeAllenComplexityStage.getInputPort());
this.connectPorts(computeAllenComplexityStage.getOutputPort(), saveAllenDataStage.getInputPort()); this.connectPorts(computeAllenComplexityStage.getOutputPort(), saveAllenDataStage.getInputPort());
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment