Changeset 2242 for trunk/autoquest-core-tasktrees/src/main
- Timestamp:
- 12/08/17 16:43:41 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskModel.java
r1948 r2242 162 162 * </p> 163 163 */ 164 private synchronized void ensureInitialized() { 165 if (index == null) { 166 index = new TaskModelIndex(); 167 168 for (IUserSession session : this.userSessions) { 169 for (ITaskInstance taskInstance : session) { 170 index.handleTaskInstance(taskInstance); 171 } 172 } 173 174 // count all events covered 175 int allEventsCovered = 0; 176 Collection<ITask> tasks = getTasks(); 177 for (ITask task : tasks) { 178 if (task instanceof IEventTask) { 179 allEventsCovered += task.getInstances().size(); 180 } 181 } 182 183 int[] eventCoverageRatios = new int[tasks.size()]; 184 int i = 0; 185 186 // add some further measures 187 for (ITask task : tasks) { 188 TaskInfo info = index.taskMap.get(task); 189 info.addMeasure(TaskMetric.EVENT_COVERAGE_RATIO); 190 191 int coveredEvents = info.getMeasureValue(TaskMetric.EVENT_COVERAGE); 192 int coverageRatio = 0; 193 194 if (allEventsCovered > 0) { 195 coverageRatio = (coveredEvents * 1000) / allEventsCovered; 196 } 197 198 eventCoverageRatios[i++] = coverageRatio; 199 info.setCount(TaskMetric.EVENT_COVERAGE_RATIO, coverageRatio); 200 } 201 202 Arrays.sort(eventCoverageRatios); 203 204 // add some further measures 205 for (ITask task : tasks) { 206 TaskInfo info = index.taskMap.get(task); 207 info.addMeasure(TaskMetric.EVENT_COVERAGE_QUANTILE); 208 int quantile = Arrays.binarySearch 209 (eventCoverageRatios, info.getMeasureValue(TaskMetric.EVENT_COVERAGE_RATIO)); 210 211 quantile = 1000 * quantile / eventCoverageRatios.length; 212 213 info.setCount(TaskMetric.EVENT_COVERAGE_QUANTILE, quantile); 214 } 215 216 //index.dumpToCSV(System.out); 217 /*try { 218 OutputStream stream = new FileOutputStream(new File("tasks.csv")); 219 index.dumpToCSV(new PrintStream(stream)); 220 stream.close(); 221 } 222 catch (FileNotFoundException e) { 223 e.printStackTrace(); 224 }*/ 225 } 226 164 private void ensureInitialized() { 165 synchronized (this) { 166 if (index == null) { 167 index = new TaskModelIndex(); 168 169 for (IUserSession session : this.userSessions) { 170 for (ITaskInstance taskInstance : session) { 171 index.handleTaskInstance(taskInstance); 172 } 173 } 174 175 // count all events covered 176 int allEventsCovered = 0; 177 Collection<ITask> tasks = getTasks(); 178 for (ITask task : tasks) { 179 if (task instanceof IEventTask) { 180 allEventsCovered += task.getInstances().size(); 181 } 182 } 183 184 int[] eventCoverageRatios = new int[tasks.size()]; 185 int i = 0; 186 187 // add some further measures 188 for (ITask task : tasks) { 189 TaskInfo info = index.taskMap.get(task); 190 info.addMeasure(TaskMetric.EVENT_COVERAGE_RATIO); 191 192 int coveredEvents = info.getMeasureValue(TaskMetric.EVENT_COVERAGE); 193 int coverageRatio = 0; 194 195 if (allEventsCovered > 0) { 196 coverageRatio = (coveredEvents * 1000) / allEventsCovered; 197 } 198 199 eventCoverageRatios[i++] = coverageRatio; 200 info.setCount(TaskMetric.EVENT_COVERAGE_RATIO, coverageRatio); 201 } 202 203 Arrays.sort(eventCoverageRatios); 204 205 // add some further measures 206 for (ITask task : tasks) { 207 TaskInfo info = index.taskMap.get(task); 208 info.addMeasure(TaskMetric.EVENT_COVERAGE_QUANTILE); 209 int quantile = Arrays.binarySearch 210 (eventCoverageRatios, info.getMeasureValue(TaskMetric.EVENT_COVERAGE_RATIO)); 211 212 quantile = 1000 * quantile / eventCoverageRatios.length; 213 214 info.setCount(TaskMetric.EVENT_COVERAGE_QUANTILE, quantile); 215 } 216 217 //index.dumpToCSV(System.out); 218 /*try { 219 OutputStream stream = new FileOutputStream(new File("tasks.csv")); 220 index.dumpToCSV(new PrintStream(stream)); 221 stream.close(); 222 } 223 catch (FileNotFoundException e) { 224 e.printStackTrace(); 225 }*/ 226 } 227 } 227 228 } 228 229
Note: See TracChangeset
for help on using the changeset viewer.