Search in sources :

Example 16 with EntryCallNode

use of org.iobserve.analysis.behavior.models.extended.EntryCallNode in project iobserve-analysis by research-iobserve.

the class ModelComparisonStage method execute.

/*
     * (non-Javadoc)
     *
     * @see teetime.framework.AbstractStage#execute()
     */
@Override
protected void execute() throws Exception {
    /**
     * We cannot use else if here, as (a) there could be an input at each input port, (b) there
     * could be a model at testModel but not at the referenceModel input, in an if-then-else
     * style, the test model would not be received until we have a reference model, which
     * unnecessarily would imply a sequence between both ports.
     */
    if (this.referenceModel == null) {
        this.referenceModel = this.referenceModelInputPort.receive();
    }
    if (this.testModel == null) {
        this.testModel = this.testModelInputPort.receive();
    }
    /**
     * We still have to check both, as there could be nothing a both ports.
     */
    if ((this.referenceModel != null) && (this.testModel != null)) {
        final ComparisonResult result = new ComparisonResult();
        result.getBaselineNodes().addAll(this.referenceModel.getNodes());
        result.getBaselineEdges().addAll(this.referenceModel.getEdges());
        result.getTestModelNodes().addAll(this.testModel.getNodes());
        result.getTestModelEdges().addAll(this.testModel.getEdges());
        /**
         * Missing nodes.
         */
        for (final EntryCallNode baselineNode : this.referenceModel.getNodes()) {
            final EntryCallNode testModelNode = this.findMatchingModelNode(this.testModel.getNodes(), baselineNode);
            if (testModelNode == null) {
                result.getMissingNodes().add(baselineNode);
            } else {
                result.getSimilarNodes().add(baselineNode);
                /**
                 * Compute mismatch in call information.
                 */
                final List<CallInformation> missingInformation = this.computeAdditionalInformation(baselineNode.getEntryCallInformation(), testModelNode.getEntryCallInformation());
                final List<CallInformation> additionalInformation = this.computeAdditionalInformation(testModelNode.getEntryCallInformation(), baselineNode.getEntryCallInformation());
                result.getNodeDifferences().add(new NodeDifference(baselineNode, testModelNode, missingInformation, additionalInformation));
            }
        }
        /**
         * Additional nodes.
         */
        for (final EntryCallNode testModelNode : this.testModel.getNodes()) {
            final EntryCallNode baselineNode = this.findMatchingModelNode(this.referenceModel.getNodes(), testModelNode);
            if (baselineNode == null) {
                result.getAdditionalNodes().add(testModelNode);
            }
        }
        /**
         * Missing edges.
         */
        int missingEdgeCount = 0;
        for (final EntryCallEdge baselineEdge : this.referenceModel.getEdges()) {
            final EntryCallEdge testModelEdge = this.findMatchingModelEdge(this.testModel.getEdges(), baselineEdge);
            if (testModelEdge == null) {
                missingEdgeCount += (int) baselineEdge.getCalls();
            } else {
                missingEdgeCount += Math.abs((int) (baselineEdge.getCalls() - testModelEdge.getCalls()));
            }
        }
        result.setMissingEdgeCount(missingEdgeCount);
        /**
         * Additional edges.
         */
        int additionalEdgeCount = 0;
        for (final EntryCallEdge testModelEdge : this.testModel.getEdges()) {
            final EntryCallEdge baselineEdge = this.findMatchingModelEdge(this.referenceModel.getEdges(), testModelEdge);
            if (baselineEdge == null) {
                additionalEdgeCount += (int) testModelEdge.getCalls();
            } else {
                additionalEdgeCount += Math.abs((int) (baselineEdge.getCalls() - testModelEdge.getCalls()));
            }
        }
        result.setAdditionalEdgeCount(additionalEdgeCount);
        /**
         * Forget models after processing to be able to process the next elements.
         */
        // NOPMD necessary to forget data
        this.referenceModel = null;
        // NOPMD necessary to forget data
        this.testModel = null;
        /**
         * Add baseline and testModelNodes
         */
        this.resultPort.send(result);
    }
}
Also used : CallInformation(org.iobserve.analysis.behavior.models.extended.CallInformation) EntryCallEdge(org.iobserve.analysis.behavior.models.extended.EntryCallEdge) EntryCallNode(org.iobserve.analysis.behavior.models.extended.EntryCallNode) NodeDifference(org.iobserve.evaluation.data.NodeDifference) ComparisonResult(org.iobserve.evaluation.data.ComparisonResult)

Example 17 with EntryCallNode

use of org.iobserve.analysis.behavior.models.extended.EntryCallNode in project iobserve-analysis by research-iobserve.

the class ModelComparisonStageTest method checkNodeLists.

/**
 * Perform the comparison.
 *
 * @param label
 * @param direction
 * @param leftNodes
 * @param rightNodes
 */
private void checkNodeLists(final String label, final String direction, final List<EntryCallNode> leftNodes, final List<EntryCallNode> rightNodes) {
    for (final EntryCallNode left : leftNodes) {
        boolean match = false;
        for (final EntryCallNode right : rightNodes) {
            if (left.getSignature().equals(right.getSignature())) {
                this.checkInformationEqual(left.getEntryCallInformation(), right.getEntryCallInformation(), label);
                match = true;
                break;
            }
        }
        Assert.assertTrue(label + ": Nodes are present in " + direction + " model. Missing " + left.getSignature(), match);
    }
}
Also used : EntryCallNode(org.iobserve.analysis.behavior.models.extended.EntryCallNode)

Example 18 with EntryCallNode

use of org.iobserve.analysis.behavior.models.extended.EntryCallNode in project iobserve-analysis by research-iobserve.

the class ComparisonOutputStage method createAllNodesList.

/**
 * Get all nodes used in this comparison.
 *
 * @param baselineNodes
 * @param testModelNodes
 * @return
 */
private List<EntryCallNode> createAllNodesList(final List<EntryCallNode> baselineNodes, final List<EntryCallNode> testModelNodes) {
    final List<EntryCallNode> result = new ArrayList<>();
    result.addAll(baselineNodes);
    for (final EntryCallNode node : testModelNodes) {
        if (!this.nodeExists(baselineNodes, node)) {
            result.add(node);
        }
    }
    return result;
}
Also used : EntryCallNode(org.iobserve.analysis.behavior.models.extended.EntryCallNode) ArrayList(java.util.ArrayList)

Example 19 with EntryCallNode

use of org.iobserve.analysis.behavior.models.extended.EntryCallNode in project iobserve-analysis by research-iobserve.

the class ComparisonOutputStage method generateNodeCallInformation.

private void generateNodeCallInformation(final BufferedWriter writer, final String prefix, final List<EntryCallNode> allNodes, final List<EntryCallNode> selectedNodes) throws IOException {
    for (final EntryCallNode referenceNode : allNodes) {
        final EntryCallNode printNode = this.findNode(selectedNodes, referenceNode);
        if (printNode != null) {
            final CallInformation[] allEntryCallInformation = this.generateAllEntryCallInformationList(referenceNode.getEntryCallInformation(), printNode.getEntryCallInformation());
            writer.write(prefix + printNode.getSignature().substring(18) + "\n");
            this.generateCallInformation(writer, prefix + "\t", allEntryCallInformation, printNode.getEntryCallInformation());
        } else {
            writer.write(prefix + " -- \n");
        }
    }
}
Also used : CallInformation(org.iobserve.analysis.behavior.models.extended.CallInformation) EntryCallNode(org.iobserve.analysis.behavior.models.extended.EntryCallNode)

Aggregations

EntryCallNode (org.iobserve.analysis.behavior.models.extended.EntryCallNode)19 CallInformation (org.iobserve.analysis.behavior.models.extended.CallInformation)9 EntryCallEdge (org.iobserve.analysis.behavior.models.extended.EntryCallEdge)9 BehaviorModel (org.iobserve.analysis.behavior.models.extended.BehaviorModel)6 AbstractUserAction (org.palladiosimulator.pcm.usagemodel.AbstractUserAction)3 Branch (org.palladiosimulator.pcm.usagemodel.Branch)3 EntryLevelSystemCall (org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall)3 Loop (org.palladiosimulator.pcm.usagemodel.Loop)3 Stop (org.palladiosimulator.pcm.usagemodel.Stop)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 SingleOrNoneCollector (org.iobserve.analysis.behavior.SingleOrNoneCollector)2 NodeDifference (org.iobserve.evaluation.data.NodeDifference)2 BranchTransition (org.palladiosimulator.pcm.usagemodel.BranchTransition)2 ScenarioBehaviour (org.palladiosimulator.pcm.usagemodel.ScenarioBehaviour)2