\r
import java.util.ArrayList;\r
import java.util.Arrays;\r
+import java.util.Comparator;\r
import java.util.Iterator;\r
import java.util.List;\r
\r
// ------------------------------------------------------------------------\r
\r
private class TraceEntry implements ITimeGraphEntry {\r
+ // The Trace\r
private CtfKernelTrace fTrace;\r
- public ArrayList<ResourcesEntry> fChildren;\r
- public String fName;\r
-\r
- public TraceEntry(CtfKernelTrace trace, String name) {\r
+ // The start time\r
+ private long fTraceStartTime;\r
+ // The end time\r
+ private long fTraceEndTime; \r
+ // The children of the entry\r
+ private ArrayList<ResourcesEntry> fChildren;\r
+ // The name of entry\r
+ private String fName;\r
+\r
+ public TraceEntry(CtfKernelTrace trace, String name, long startTime, long endTime) {\r
fTrace = trace;\r
fChildren = new ArrayList<ResourcesEntry>();\r
fName = name;\r
+ fTraceStartTime = startTime;\r
+ fTraceEndTime = endTime;\r
}\r
\r
@Override\r
\r
@Override\r
public long getStartTime() {\r
- return -1;\r
+ return fTraceStartTime;\r
}\r
\r
@Override\r
public long getEndTime() {\r
- return -1;\r
+ return fTraceEndTime;\r
}\r
\r
@Override\r
fChildren.add(index, entry);\r
}\r
}\r
+ \r
+ private static class TraceEntryComparator implements Comparator<ITimeGraphEntry> {\r
+ @Override\r
+ public int compare(ITimeGraphEntry o1, ITimeGraphEntry o2) {\r
+ int result = o1.getStartTime() < o2.getStartTime() ? -1 : o1.getStartTime() > o2.getStartTime() ? 1 : 0;\r
+ if (result == 0) {\r
+ result = o1.getName().compareTo(o2.getName());\r
+ }\r
+ return result;\r
+ }\r
+ }\r
\r
private class ZoomThread extends Thread {\r
private long fZoomStartTime;\r
for (ITmfTrace<?> trace : experiment.getTraces()) {\r
if (trace instanceof CtfKernelTrace) {\r
CtfKernelTrace ctfKernelTrace = (CtfKernelTrace) trace;\r
- TraceEntry groupEntry = new TraceEntry(ctfKernelTrace, trace.getName());\r
- entryList.add(groupEntry);\r
IStateSystemQuerier ssq = ctfKernelTrace.getStateSystem();\r
long startTime = ssq.getStartTime();\r
long endTime = ssq.getCurrentEndTime() + 1;\r
+ TraceEntry groupEntry = new TraceEntry(ctfKernelTrace, trace.getName(), startTime, endTime);\r
+ entryList.add(groupEntry);\r
fStartTime = Math.min(fStartTime, startTime);\r
fEndTime = Math.max(fEndTime, endTime);\r
List<Integer> cpuQuarks = ssq.getQuarks(Attributes.CPUS, "*"); //$NON-NLS-1$\r
return;\r
}\r
ITimeGraphEntry[] entries = fEntryList.toArray(new ITimeGraphEntry[0]);\r
- Arrays.sort(entries);\r
+ Arrays.sort(entries, new TraceEntryComparator());\r
fTimeGraphViewer.setInput(entries);\r
fTimeGraphViewer.setTimeBounds(fStartTime, fEndTime);\r
\r