ProcessTimeline.java
Go to the documentation of this file.00001 package edu.rice.cs.hpc.traceviewer.data.timeline;
00002
00003 import java.util.HashMap;
00004
00005 import org.eclipse.core.runtime.Assert;
00006
00007 import edu.rice.cs.hpc.data.experiment.extdata.AbstractBaseData;
00008 import edu.rice.cs.hpc.data.experiment.extdata.IBaseData;
00009 import edu.rice.cs.hpc.traceviewer.data.db.TraceDataByRank;
00010 import edu.rice.cs.hpc.traceviewer.data.db.DataRecord;
00011 import edu.rice.cs.hpc.traceviewer.data.graph.CallPath;
00012
00014 public class ProcessTimeline {
00015
00017 private HashMap<Integer, CallPath> scopeMap;
00018
00020 private int lineNum;
00021
00023 private long startingTime;
00024
00026 private long timeRange;
00027
00029 private double pixelLength;
00030
00031 final TraceDataByRank data;
00032
00033
00034
00035
00036
00037
00042 public ProcessTimeline(int _lineNum, HashMap<Integer, CallPath> _scopeMap, IBaseData dataTrace,
00043 int _processNumber, int _numPixelH, long _timeRange, long _startingTime)
00044 {
00045
00046 lineNum = _lineNum;
00047 scopeMap = _scopeMap;
00048
00049 timeRange = _timeRange;
00050 startingTime = _startingTime;
00051
00052 pixelLength = timeRange / (double) _numPixelH;
00053
00054
00055 if (dataTrace instanceof AbstractBaseData)
00056 data = new TraceDataByRank((AbstractBaseData) dataTrace, _processNumber, _numPixelH);
00057 else
00058 data = new TraceDataByRank(new DataRecord[0]);
00059 }
00060
00061
00062 public ProcessTimeline(TraceDataByRank _data,
00063 HashMap<Integer, CallPath> _scopeMap, int _processNumber,
00064 int _numPixelH, long _timeRange, long _startingTime) {
00065 lineNum = _processNumber;
00066 scopeMap = _scopeMap;
00067
00068 timeRange = _timeRange;
00069 startingTime = _startingTime;
00070
00071 pixelLength = timeRange / (double) _numPixelH;
00072 if (_data == null)
00073 data = new TraceDataByRank(new DataRecord[0]);
00074 else
00075 data = _data;
00076 }
00077
00082 public void readInData() {
00083
00084 data.getData(startingTime, timeRange,
00085 pixelLength);
00086 }
00087
00089 public long getTime(int sample) {
00090 return data.getTime(sample);
00091 }
00092
00094 private int getCpid(int sample) {
00095 return data.getCpid(sample);
00096 }
00097
00098 public void shiftTimeBy(long lowestStartingTime) {
00099 data.shiftTimeBy(lowestStartingTime);
00100 }
00101
00103 public CallPath getCallPath(int sample, int depth) {
00104 Assert.isTrue(sample>=0, "sample number is negative");
00105 int cpid = getCpid(sample);
00106
00107 CallPath cp = scopeMap.get(cpid);
00108 if (cp == null) {
00109 System.err.println("ERROR: No sample found for cpid " + cpid
00110 + " in trace sample: " + sample);
00111 System.err
00112 .println("\tThere was most likely an error in the data collection; the display may be inaccurate.");
00113 }
00114 return cp;
00115 }
00120 public void copyDataFrom(ProcessTimeline another) {
00121 this.data.setListOfData(another.data.getListOfData());
00122 }
00123
00125 public int size() {
00126 return data.size();
00127 }
00128
00130 public int line() {
00131 return lineNum;
00132 }
00133
00141 public int findMidpointBefore(long time, boolean usingMidpoint)
00142 {
00143 return data.findMidpointBefore(time, usingMidpoint);
00144 }
00145
00146
00147
00148
00149
00150 public TraceDataByRank getData()
00151 {
00152 return data;
00153 }
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169 }