From db55e08c4d16191f8f67a0858c20dccfd94ece8a Mon Sep 17 00:00:00 2001 From: Ludovic Apvrille <ludovic.apvrille@telecom-paristech.fr> Date: Thu, 8 Sep 2011 16:35:08 +0000 Subject: [PATCH] DSE: Update on results (bus, tasks) --- src/dseengine/BusContentionWholeResult.java | 90 +++++++++++ src/dseengine/BusWholeResult.java | 96 +++++++++++ src/dseengine/CPUWholeResult.java | 131 +++++++++++++++ src/dseengine/DSEConfiguration.java | 15 ++ src/dseengine/DSESimulationResult.java | 166 +++++++++++--------- src/dseengine/TaskWholeResult.java | 117 ++++++++++++++ 6 files changed, 542 insertions(+), 73 deletions(-) create mode 100755 src/dseengine/BusContentionWholeResult.java create mode 100755 src/dseengine/BusWholeResult.java create mode 100755 src/dseengine/CPUWholeResult.java create mode 100755 src/dseengine/TaskWholeResult.java diff --git a/src/dseengine/BusContentionWholeResult.java b/src/dseengine/BusContentionWholeResult.java new file mode 100755 index 0000000000..f547a5fadd --- /dev/null +++ b/src/dseengine/BusContentionWholeResult.java @@ -0,0 +1,90 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + +ludovic.apvrille AT enst.fr + +This software is a computer program whose purpose is to allow the +edition of TURTLE analysis, design and deployment diagrams, to +allow the generation of RT-LOTOS or Java code from this diagram, +and at last to allow the analysis of formal validation traces +obtained from external tools, e.g. RTL from LAAS-CNRS and CADP +from INRIA Rhone-Alpes. + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +/** +* Class BusContentionWholeResult +* Object for storing a bus contention result after a simulation +* Creation: 07/09/2011 +* @version 1.0 07/09/2011 +* @author Ludovic APVRILLE +* @see +*/ + +package dseengine; + +import java.io.*; +import java.util.*; + + +import myutil.*; + + +//import uppaaldesc.*; + +public class BusContentionWholeResult { + public int id; + public String name; + + public long minContention; + public long maxContention; + public long averageContention; + public int nbOfResults; + + public BusContentionWholeResult(BusContentionResult bct) { + id = bct.id; + name = bct.name; + minContention = bct.contention; + maxContention = bct.contention; + averageContention = bct.contention; + nbOfResults = 1; + } + + public void updateResults(BusContentionResult bct) { + minContention = Math.min(minContention, bct.contention); + maxContention = Math.max(maxContention, bct.contention); + averageContention = ((averageContention * nbOfResults)+bct.contention)/(nbOfResults + 1); + nbOfResults ++; + } + + public String toStringResult(int idcpu, String nameCPU) { + return "CPU_BUS_CONTENTION " + idcpu + " " + nameCPU + " " + id + " " + name + " " + nbOfResults + " " + minContention + " " + averageContention + " " + maxContention; + } + + + +} // Class BusContentionWholeResult + diff --git a/src/dseengine/BusWholeResult.java b/src/dseengine/BusWholeResult.java new file mode 100755 index 0000000000..ddd52e4427 --- /dev/null +++ b/src/dseengine/BusWholeResult.java @@ -0,0 +1,96 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + +ludovic.apvrille AT enst.fr + +This software is a computer program whose purpose is to allow the +edition of TURTLE analysis, design and deployment diagrams, to +allow the generation of RT-LOTOS or Java code from this diagram, +and at last to allow the analysis of formal validation traces +obtained from external tools, e.g. RTL from LAAS-CNRS and CADP +from INRIA Rhone-Alpes. + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +/** +* Class BusWholeResult +* Object for storing a whole bus result after a simulation +* Creation: 07/09/2011 +* @version 1.0 07/09/2011 +* @author Ludovic APVRILLE +* @see +*/ + +package dseengine; + +import java.io.*; +import java.util.*; + + +import myutil.*; + + +//import uppaaldesc.*; + +public class BusWholeResult { + public int id; + public String name; + + public double minUtilization; + public double maxUtilization; + public double averageUtilization; + public int nbOfResults; + + public BusWholeResult(BusResult resbus) { + + id = resbus.id; + name = resbus.name; + minUtilization = resbus.utilization; + maxUtilization = resbus.utilization; + averageUtilization = resbus.utilization; + nbOfResults = 1; + } + + public void updateResults(BusResult resbus) { + minUtilization = Math.min(minUtilization, resbus.utilization); + maxUtilization = Math.max(maxUtilization, resbus.utilization); + averageUtilization = ((averageUtilization * nbOfResults)+resbus.utilization)/(nbOfResults + 1); + nbOfResults ++; + } + + + public String toStringResult() { + StringBuffer sb = new StringBuffer(""); + sb.append("BUS " + id + " " + name + " " + nbOfResults + " " + minUtilization + " " + averageUtilization + " " + maxUtilization ); + + + return sb.toString(); + } + + + +} // Class BusResult + diff --git a/src/dseengine/CPUWholeResult.java b/src/dseengine/CPUWholeResult.java new file mode 100755 index 0000000000..8c76dd6b42 --- /dev/null +++ b/src/dseengine/CPUWholeResult.java @@ -0,0 +1,131 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + +ludovic.apvrille AT enst.fr + +This software is a computer program whose purpose is to allow the +edition of TURTLE analysis, design and deployment diagrams, to +allow the generation of RT-LOTOS or Java code from this diagram, +and at last to allow the analysis of formal validation traces +obtained from external tools, e.g. RTL from LAAS-CNRS and CADP +from INRIA Rhone-Alpes. + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +/** +* Class CPUWholeResult +* Object for storing all CPU simulation results +* Creation: 07/09/2011 +* @version 1.0 07/09/2011 +* @author Ludovic APVRILLE +* @see +*/ + +package dseengine; + +import java.io.*; +import java.util.*; + + +import myutil.*; + + +//import uppaaldesc.*; + +public class CPUWholeResult { + public int id; + public String name; + + public double minUtilization; + public double maxUtilization; + public double averageUtilization; + public int nbOfResults; + + public Vector<BusContentionWholeResult> contentions; + Hashtable contentionTable = new Hashtable(); + + public CPUWholeResult(CPUResult rescpu) { + contentionTable = new Hashtable(); + + id = rescpu.id; + name = rescpu.name; + minUtilization = rescpu.utilization; + maxUtilization = rescpu.utilization; + averageUtilization = rescpu.utilization; + nbOfResults = 1; + + workOnContentions(rescpu); + } + + public void updateResults(CPUResult rescpu) { + minUtilization = Math.min(minUtilization, rescpu.utilization); + maxUtilization = Math.max(maxUtilization, rescpu.utilization); + averageUtilization = ((averageUtilization * nbOfResults)+rescpu.utilization)/(nbOfResults + 1); + nbOfResults ++; + workOnContentions(rescpu); + } + + public void workOnContentions(CPUResult rescpu) { + Object o; + BusContentionWholeResult bcwr; + + if (rescpu.contentions != null) { + for(BusContentionResult ct: rescpu.contentions) { + o = contentionTable.get(ct.id); + if (o == null) { + bcwr = new BusContentionWholeResult(ct); + contentionTable.put(ct.id, bcwr); + addContentionOnBus(bcwr); + } else { + bcwr = (BusContentionWholeResult)o; + bcwr.updateResults(ct); + } + } + } + } + + public void addContentionOnBus(BusContentionWholeResult ct) { + if (contentions == null) { + contentions = new Vector<BusContentionWholeResult>(); + } + + contentions.add(ct); + } + + public String toStringResult() { + StringBuffer sb = new StringBuffer(""); + sb.append("CPU " + id + " " + name + " " + nbOfResults + " " + minUtilization + " " + averageUtilization + " " + maxUtilization); + if (contentions != null) { + for(BusContentionWholeResult bcwr: contentions) { + sb.append("\n" + bcwr.toStringResult(id, name)); + } + } + + return sb.toString(); + } + +} // Class CPUWholeResult + diff --git a/src/dseengine/DSEConfiguration.java b/src/dseengine/DSEConfiguration.java index a47624804f..2311537ac3 100755 --- a/src/dseengine/DSEConfiguration.java +++ b/src/dseengine/DSEConfiguration.java @@ -459,11 +459,26 @@ public class DSEConfiguration { } public int computeResults(String _arguments, boolean _debug, boolean _optimize) { + TraceManager.addDev("Computing results"); + if (results == null) { + TraceManager.addDev("No results"); return -1; } // Must compute results + results.computeResults(); + + TraceManager.addDev("Results: #" + resultsID + "\n" + results.getWholeResults()); + + // Saving to file + try { + FileUtils.saveFile(pathToResults + "results" + resultsID + ".txt", results.getExplanationHeader() + "\n\n" + results.getWholeResults()); + } catch (Exception e){ + TraceManager.addDev("Error when saving results file"); + return -1; + + } // Reinit results results.reset(); diff --git a/src/dseengine/DSESimulationResult.java b/src/dseengine/DSESimulationResult.java index 162c38f107..fc6faee0bd 100755 --- a/src/dseengine/DSESimulationResult.java +++ b/src/dseengine/DSESimulationResult.java @@ -72,6 +72,10 @@ public class DSESimulationResult { private Vector<BusResult> busses; private Vector<TaskResult> tasks; + private Vector<CPUWholeResult> wcpus; + private Vector<BusWholeResult> wbusses; + private Vector<TaskWholeResult> wtasks; + public DSESimulationResult() { reset(); } @@ -92,7 +96,6 @@ public class DSESimulationResult { analyzeServerAnswer(data); - return 0; } @@ -123,6 +126,9 @@ public class DSESimulationResult { TraceManager.addDev("infos on busses:" + busses.size()); TraceManager.addDev("infos on tasks:" + tasks.size()); + + // Compute results! + //System.out.println("toto4"); } @@ -399,78 +405,6 @@ public class DSESimulationResult { return true; } - - - /*if (elt.getTagName().compareTo(SIMULATION_CPU) == 0) { - id = null; - name = null; - command = null; - contdel = null; - busname = null; - busid = null; - - id = elt.getAttribute("id"); - name = elt.getAttribute("name"); - nl = elt.getElementsByTagName("util"); - if ((nl != null) && (nl.getLength() > 0)) { - node0 = nl.item(0); - //System.out.println("nl:" + nl + " value=" + node0.getNodeValue() + " content=" + node0.getTextContent()); - util = node0.getTextContent(); - } - - //System.out.println("toto12"); - nl = elt.getElementsByTagName("contdel"); - if ((nl != null) && (nl.getLength() > 0)) { - nl = elt.getElementsByTagName("contdel"); - node0 = nl.item(0); - elt0 = (Element)node0; - busid = elt0.getAttribute("busID"); - busname = elt0.getAttribute("busName"); - //System.out.println("nl:" + nl + " value=" + node0.getNodeValue() + " content=" + node0.getTextContent()); - contdel = node0.getTextContent(); - } - - //System.out.println("contdel: " + contdel + " busID:" + busid + " busName:" + busname); - - - if ((id != null) && (util != null)) { - updateCPUState(id, util, contdel, busname, busid); - } - } - - //System.out.println("toto2"); - - if (elt.getTagName().compareTo(SIMULATION_BUS) == 0) { - id = null; - name = null; - command = null; - id = elt.getAttribute("id"); - name = elt.getAttribute("name"); - nl = elt.getElementsByTagName("util"); - if ((nl != null) && (nl.getLength() > 0)) { - node0 = nl.item(0); - //System.out.println("nl:" + nl + " value=" + node0.getNodeValue() + " content=" + node0.getTextContent()); - util = node0.getTextContent(); - } - - //System.out.println("Got info on bus " + id + " util=" + util); - - if ((id != null) && (util != null)) { - updateBusState(id, util); - } - } - - - } - } - } - } catch (Exception e) { - TraceManager.addError("Exception in xml parsing " + e.getMessage() + " node= " + node1); - return false; - } - - return true; - }*/ public static String decodeString(String s) { if (s == null) @@ -484,6 +418,92 @@ public class DSESimulationResult { } } + public void computeResults() { + + Hashtable resultsTable = new Hashtable(); + Object o; + CPUWholeResult cpuwr; + BusWholeResult buswr; + TaskWholeResult taskwr; + + // CPUs + wcpus = new Vector<CPUWholeResult>(); + for(CPUResult rescpu: cpus) { + o = resultsTable.get(rescpu.id); + //TraceManager.addDev("Got o=" + o); + if (o == null) { + cpuwr = new CPUWholeResult(rescpu); + resultsTable.put(rescpu.id, cpuwr); + wcpus.add(cpuwr); + + } else { + cpuwr = (CPUWholeResult)o; + cpuwr.updateResults(rescpu); + } + } + + wbusses = new Vector<BusWholeResult>(); + for(BusResult resbus: busses) { + o = resultsTable.get(resbus.id); + //TraceManager.addDev("Got o=" + o); + if (o == null) { + buswr = new BusWholeResult(resbus); + resultsTable.put(resbus.id, buswr); + wbusses.add(buswr); + + } else { + buswr = (BusWholeResult)o; + buswr.updateResults(resbus); + } + } + + wtasks = new Vector<TaskWholeResult>(); + for(TaskResult restask: tasks) { + o = resultsTable.get(restask.id); + //TraceManager.addDev("Got o=" + o); + if (o == null) { + taskwr = new TaskWholeResult(restask); + resultsTable.put(restask.id, taskwr); + wtasks.add(taskwr); + + } else { + taskwr = (TaskWholeResult)o; + taskwr.updateResults(restask); + } + } + + //TraceManager.addDev("Done compte results"); + } + + public String getWholeResults() { + StringBuffer sb = new StringBuffer(""); + for(CPUWholeResult reswcpu: wcpus) { + sb.append(reswcpu.toStringResult() + "\n"); + } + + for(BusWholeResult reswbus: wbusses) { + sb.append(reswbus.toStringResult() + "\n"); + } + + for(TaskWholeResult reswtask: wtasks) { + sb.append(reswtask.toStringResult() + "\n"); + } + + + + + return sb.toString(); + } + + public static String getExplanationHeader() { + String s; + s = "# CPUs: CPU ID Name nbOfResults minUtilization averageUtilization maxUtilization\n"; + s += "# Contention on busses: CPU_BUS_CONTENTION CPUID CPUName BusID BusName nbOfResults minContentionDelay averageContentionDelay maxContentionDelay\n"; + s += "# Busses: BUS ID Name nbOfResults minUtilization averageUtilization maxUtilization\n"; + s += "# Tasks: TASK ID Name nbOfResults minExecutedCycles averageExecutedCycles maxExecutedCycles nbOfRunnable nbOfTerminated\n"; + return s; + } + diff --git a/src/dseengine/TaskWholeResult.java b/src/dseengine/TaskWholeResult.java new file mode 100755 index 0000000000..87ed79531c --- /dev/null +++ b/src/dseengine/TaskWholeResult.java @@ -0,0 +1,117 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + +ludovic.apvrille AT enst.fr + +This software is a computer program whose purpose is to allow the +edition of TURTLE analysis, design and deployment diagrams, to +allow the generation of RT-LOTOS or Java code from this diagram, +and at last to allow the analysis of formal validation traces +obtained from external tools, e.g. RTL from LAAS-CNRS and CADP +from INRIA Rhone-Alpes. + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +/** +* Class TaskWholeResult +* Object for storing a whole task result after a simulation +* Creation: 08/09/2011 +* @version 1.0 08/09/2011 +* @author Ludovic APVRILLE +* @see +*/ + +package dseengine; + +import java.io.*; +import java.util.*; + + +import myutil.*; + + +//import uppaaldesc.*; + +public class TaskWholeResult { + public int id; + public String name; + + public double minNbOfExecutedCycles; + public double maxNbOfExecutedCycles; + public double averageNbOfExecutedCycles; + public int nbOfResults; + + public int nbOfRunnableStates; + public int nbOfTerminatedStates; + + public TaskWholeResult(TaskResult taskres) { + + id = taskres.id; + name = taskres.name; + minNbOfExecutedCycles = taskres.nbOfExecutedCycles; + maxNbOfExecutedCycles = taskres.nbOfExecutedCycles; + averageNbOfExecutedCycles = taskres.nbOfExecutedCycles; + nbOfResults = 1; + + if (taskres.state.toLowerCase().compareTo("runnable") == 0) { + nbOfRunnableStates = 1 ; + } else { + nbOfRunnableStates = 0 ; + } + + if (taskres.state.toLowerCase().compareTo("terminated") == 0) { + nbOfRunnableStates = 1 ; + } else { + nbOfRunnableStates = 0 ; + } + } + + public void updateResults(TaskResult restask) { + minNbOfExecutedCycles = Math.min(minNbOfExecutedCycles, restask.nbOfExecutedCycles); + maxNbOfExecutedCycles = Math.max(maxNbOfExecutedCycles, restask.nbOfExecutedCycles); + averageNbOfExecutedCycles = ((averageNbOfExecutedCycles * nbOfResults)+restask.nbOfExecutedCycles)/(nbOfResults + 1); + if (restask.state.toLowerCase().compareTo("runnable") == 0) { + nbOfRunnableStates ++ ; + } + if (restask.state.toLowerCase().compareTo("terminated") == 0) { + nbOfRunnableStates ++ ; + } + nbOfResults ++; + } + + + public String toStringResult() { + StringBuffer sb = new StringBuffer(""); + sb.append("TASK " + id + " " + name + " " + nbOfResults + " " + minNbOfExecutedCycles + " " + averageNbOfExecutedCycles + " " + maxNbOfExecutedCycles + " " + nbOfRunnableStates + " " + nbOfTerminatedStates); + + + return sb.toString(); + } + + + +} // Class BusResult + -- GitLab