Мне нужен способ пересчитать среднюю продолжительность моих задач после каждого цикла планирования.
Как это можно сделать?
Вот мой код:
/**
* Parse a DAX file with jdom
*/
private void parseXmlFile() {
try {
SAXBuilder builder = new SAXBuilder();
// parse using builder to get DOM representation of the XML file
Document dom = builder.build(new File(daxPath));
Element root = dom.getRootElement();
List list = root.getChildren();
int idIndex = 1;
for (Iterator it = list.iterator(); it.hasNext();) {
Element node = (Element) it.next();
if (node.getName().toLowerCase().equals("job")) {
long length = 0;
String nodeName = node.getAttributeValue("id");
String nodeType = node.getAttributeValue("name");
// capture runtime. If not exist, by default the runtime is 0
double runtime = 0.0;
if (this.mName2Runtime.containsKey(nodeName)) {
runtime = 1000 * (Double) this.mName2Runtime.get(nodeName);
length = (long) runtime;
} else if (node.getAttributeValue("runtime") != null) {
String nodeTime = node.getAttributeValue("runtime");
runtime = 1000 * Double.parseDouble(nodeTime);
length = (long) runtime;
} else {
Log.printLine("Cannot find runtime for " + nodeName + ",set it to be 0");
}
}
sum+=runtime;
num++;
avg=sum/num;
// ...
}
// ...
}
// ...
}