calcSelfTime();
this.mainResourceStartIndex = findMainResourceStartTime();
this.mainResourceResponseTime = findMainResourceResponseTime();
JsonTraverser traverser = new JsonTraverser();
JsonTraverser.JsonVisitor visitor = new JsonTraverser.JsonVisitor() {
public void postProcess() {
}
public void visit(JsonObject node) throws JsonException {
int type = (int) (node.get("type").asNumber().getInteger());
switch (type) {
// Look for DOMContentLoaded & Load events
case EventRecordType.DOM_CONTENT_LOADED:
domContentLoadedTime = node.get("time").asNumber().getDecimal();
break;
case EventRecordType.LOAD_EVENT:
loadEventTime = node.get("time").asNumber().getDecimal();
break;
// Aggregate event type times.
case EventRecordType.JAVASCRIPT_EXECUTION:
javaScriptExecutionDuration += node.get("selfTime").asNumber().getDecimal();
break;
case EventRecordType.LAYOUT_EVENT:
layoutDuration += node.get("selfTime").asNumber().getDecimal();
break;
case EventRecordType.RECALC_STYLE_EVENT:
styleRecalculationDuration += node.get("selfTime").asNumber().getDecimal();
break;
case EventRecordType.EVAL_SCRIPT_EVENT:
evalScriptDuration += node.get("selfTime").asNumber().getDecimal();
break;
case EventRecordType.GC_EVENT:
garbageCollectionDuration += node.get("selfTime").asNumber().getDecimal();
break;
case EventRecordType.PAINT_EVENT:
paintDuration += node.get("selfTime").asNumber().getDecimal();
break;
case EventRecordType.PARSE_HTML_EVENT:
parseHtmlDuration += node.get("selfTime").asNumber().getDecimal();
break;
}
}
};
for (int i = this.mainResourceStartIndex, length = records.getLength(); i < length; ++i) {
traverser.traversePreOrder(records.get(i).asObject(), visitor);
}
}