DataPreparation.java
Go to the documentation of this file.00001 package edu.rice.cs.hpc.traceviewer.data.db;
00002
00003 import org.eclipse.swt.graphics.Color;
00004
00005 import edu.rice.cs.hpc.traceviewer.data.graph.CallPath;
00006 import edu.rice.cs.hpc.traceviewer.data.graph.ColorTable;
00007 import edu.rice.cs.hpc.traceviewer.data.timeline.ProcessTimeline;
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 public abstract class DataPreparation
00019 {
00020 final protected ProcessTimeline ptl;
00021 final protected int depth;
00022 final protected int height;
00023 final protected double pixelLength;
00024 final protected ColorTable colorTable;
00025 final private long begTime;
00026 final private boolean usingMidpoint;
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 public DataPreparation(ColorTable _colorTable, ProcessTimeline _ptl,
00041 long _begTime, int _depth, int _height, double _pixelLength, boolean _usingMidpoint)
00042 {
00043 this.ptl = _ptl;
00044 this.depth = _depth;
00045 this.height = _height;
00046 this.pixelLength = _pixelLength;
00047 this.colorTable = _colorTable;
00048 this.begTime = _begTime;
00049 this.usingMidpoint = _usingMidpoint;
00050 }
00051
00053 public void collect()
00054 {
00055 int succSampleMidpoint = (int) Math.max(0, (ptl.getTime(0)-begTime)/pixelLength);
00056
00057 CallPath cp = ptl.getCallPath(0, depth);
00058 if (cp==null)
00059 return;
00060
00061 String succFunction = cp.getScopeAt(depth).getName();
00062 Color succColor = colorTable.getColor(succFunction);
00063 int last_ptl_index = ptl.size() - 1;
00064
00065 for (int index = 0; index < ptl.size(); index++)
00066 {
00067
00068 if (cp==null)
00069 return;
00070
00071
00072 final int currDepth = cp.getMaxDepth();
00073 int currSampleMidpoint = succSampleMidpoint;
00074
00075
00076
00077
00078 boolean still_the_same = true;
00079 int indexSucc = index;
00080 int end = index;
00081
00082 final Color currColor = succColor;
00083
00084 while (still_the_same && (++indexSucc <= last_ptl_index))
00085 {
00086 cp = ptl.getCallPath(indexSucc, depth);
00087 if(cp != null)
00088 {
00089 succFunction = cp.getScopeAt(depth).getName();
00090 succColor = colorTable.getColor(succFunction);
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 still_the_same = (succColor.equals(currColor)) && currDepth == cp.getMaxDepth();
00101 if (still_the_same)
00102 end = indexSucc;
00103 }
00104 }
00105
00106 if (end < last_ptl_index)
00107 {
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119 double succ = usingMidpoint ? midpoint(ptl.getTime(end),ptl.getTime(end+1)) : ptl.getTime(end+1);
00120 succSampleMidpoint = (int) Math.max(0, ((succ-begTime)/pixelLength));
00121 }
00122 else
00123 {
00124
00125
00126
00127
00128
00129
00130 succSampleMidpoint = (int) Math.max(0, ((ptl.getTime(end)-begTime)/pixelLength));
00131 }
00132
00133 finishLine(currSampleMidpoint, succSampleMidpoint, currDepth, currColor, end - index + 1);
00134 index = end;
00135 }
00136 }
00137
00139 private static long midpoint(long x1, long x2)
00140 {
00141 return (x1 + x2)/2;
00142 }
00143
00144 public abstract TimelineDataSet getList();
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155 public abstract void finishLine(int currSampleMidpoint, int succSampleMidpoint, int currDepth, Color color, int sampleCount);
00156 }