Skip to content

Commit

Permalink
Refactor timeline log and improve frame boundary determination.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmpenn committed Jan 28, 2025
1 parent 8533029 commit 7595728
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,22 @@ private void doDrawing(Graphics g) {
g2d.fillRect(50, jobY, 20, 20);
g2d.setPaint( Color.BLACK );
jobY += 20;
JobSpecification jobSpec = tvc.jobSpecificationMap.getJobSpecification(jobExec.id);
double duration = jobExec.stop - jobExec.start;

g2d.setFont(dataFont);
g2d.drawString(jobExec.id, 100, jobY);
g2d.drawString(jobSpec.jobClass, 180, jobY);
g2d.drawString( String.format("%12.6f", jobExec.start), 420, jobY);
g2d.drawString( String.format("%12.6f", jobExec.stop), 520, jobY);
g2d.drawString( String.format("%12.6f", duration), 620, jobY);
g2d.drawString(jobSpec.name, 740, jobY);

JobSpecification jobSpec = tvc.jobSpecificationMap.getJobSpecification(jobExec.id);
if ( jobSpec == null) {
g2d.drawString("???", 180, jobY);
g2d.drawString("???", 740, jobY);
} else {
g2d.drawString(jobSpec.jobClass, 180, jobY);
g2d.drawString(jobSpec.name, 740, jobY);
}
}
frame.SortByJobEventDuration();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
* Class JobExecutionEvent represents one execution/run of a Trick job.
* <id> identifies the job. <start> and <stop> specify the
* clock times at which the job started and finished.
* <isEOF> and <isTOF> indicate whether the job was run as
* an "end-of-frame", or a "top-of-frame" job.
* <isTOF> indicates whether the job was run as
* an "top-of-frame" job.
*/
class JobExecutionEvent {
public String id;
public boolean isEOF;
public boolean isTOF;
public boolean isEOF;
public double start;
public double stop;
public int contained;
Expand All @@ -35,8 +35,8 @@ class JobExecutionEvent {
*/
public JobExecutionEvent(String id, boolean isTOF, boolean isEOF, double start, double stop) {
this.id = id;
this.isEOF = isEOF;
this.isTOF = isTOF;
this.isEOF = isEOF;
this.start = start;
this.stop = stop;
contained = 1;
Expand Down
24 changes: 13 additions & 11 deletions trick_source/java/src/main/java/trick/jobperf/JobPerf.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public JobPerf( String[] args ) {
String filesDir = Paths.get(timeLineFileName).toAbsolutePath().getParent().toString();
System.out.println( "\n\nFilesDir = " + filesDir + "\n\n");


// Generate the JobSpecificationMap from information extracted from the S_job_execution
// file, that should be in the same directory as the time-line file.
File s_job_execution_file = new File( filesDir + "/S_job_execution" );
Expand Down Expand Up @@ -103,7 +102,7 @@ public JobPerf( String[] args ) {
System.exit(0);
}

jobExecEvtList = getJobExecutionEventList(timeLineFileName);
jobExecEvtList = getJobExecutionEventList(timeLineFileName, jobSpecificationMap);

if (printReport) {
jobStats = new JobStats(jobExecEvtList);
Expand Down Expand Up @@ -150,7 +149,8 @@ private static void printHelpText() {
/**
* Read the timeline file, resulting in a ArrayList<JobExecutionEvent>.
*/
private ArrayList<JobExecutionEvent> getJobExecutionEventList( String fileName ) {
private ArrayList<JobExecutionEvent> getJobExecutionEventList( String fileName,
JobSpecificationMap jobSpecificationMap ) {
String line;
String field[];

Expand All @@ -162,16 +162,18 @@ private ArrayList<JobExecutionEvent> getJobExecutionEventList( String fileName )
line = in.readLine();
while( (line = in.readLine()) !=null) {
field = line.split(",");
// Need to strip trailing 0's from the id to make the ID's in
// 1) timeline file and 2) the S_job_execution file consistent.
String id = field[0].replaceAll("0*$","");

String id = field[0].trim();
JobSpecification jobSpec = jobSpecificationMap.getJobSpecification(id);
boolean isTOF = false;
if (Integer.parseInt(field[1]) == 1) isTOF = true;
boolean isEOF = false;
if (Integer.parseInt(field[2]) == 1) isEOF = true;
double start = Double.parseDouble( field[3]);
double stop = Double.parseDouble( field[4]);

if (jobSpec.jobClass.equals("top_of_frame")) {
isTOF = true;
} else if (jobSpec.jobClass.equals("end_of_frame")) {
isEOF = true;
}
double start = Double.parseDouble( field[1]);
double stop = Double.parseDouble( field[2]);
if (start < stop) {
JobExecutionEvent evt = new JobExecutionEvent(id, isTOF, isEOF, start, stop);
jobExecEvtList.add( evt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public JobSpecificationMap( File file ) throws IOException, FileNotFoundExceptio
if (field.length == 9) {
String jobclass = field[2].trim();
int phase = Integer.parseInt( field[3].trim());
String id = field[7].trim();
String id = String.format("%.2f", Double.parseDouble( field[7].trim()));
String name = field[8].trim();
// System.out.println( "JobSpec = <" + id + "," + name + "," + jobclass + ">\n\n");
jobSpecMap.put(id, new JobSpecification(name, jobclass, phase));
//System.out.println("JobSpec = " + id + "," + jobclass + "," + name);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,13 @@ public TraceViewCanvas( ArrayList<JobExecutionEvent> jobExecEvtList,

try {
boolean wasTOF = false;
boolean wasEOF = false;

List<FrameRecord> frameList = new ArrayList<FrameRecord>();
FrameRecord frameRecord = new FrameRecord();
for (JobExecutionEvent jobExec : jobExecEvtList ) {

if (!wasTOF && jobExec.isTOF) {
if ((!wasTOF && jobExec.isTOF) || ( wasEOF && !jobExec.isEOF )) {
// Wrap up the previous frame record.
frameRecord.stop = jobExec.start;
frameRecord.CalculateJobContainment();
Expand All @@ -105,6 +106,8 @@ public TraceViewCanvas( ArrayList<JobExecutionEvent> jobExecEvtList,
frameRecord.jobEvents.add(jobExec);

wasTOF = jobExec.isTOF;
wasEOF = jobExec.isEOF;

idToColorMap.addKey(jobExec.id);
}

Expand Down
7 changes: 2 additions & 5 deletions trick_source/sim_services/FrameLog/FrameLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,17 +603,14 @@ int Trick::FrameLog::shutdown() {
exit(0);
}

fprintf(fp_log,"jobID,isTopOfFrame,isEndOfFrame,startTime,stopTime\n");
fprintf(fp_log,"jobID,startTime,stopTime\n");

time_scale = 1.0 / exec_get_time_tic_value();
tl = timeline[thread_num];
for ( ii = 0 ; ii < tl_count[thread_num] ; ii++ ) {
start = tl[ii].start * time_scale;
stop = tl[ii].stop * time_scale;
int isTrickJob = (tl[ii].trick_job) ? 1 : 0;
int isEndOfFrame = (tl[ii].isEndOfFrame) ? 1 : 0;
int isTopOfFrame = (tl[ii].isTopOfFrame) ? 1 : 0;
fprintf(fp_log,"%f,%d,%d,%f,%f\n", tl[ii].id, isTopOfFrame, isEndOfFrame, start, stop);
fprintf(fp_log,"%5.2f, %f, %f\n", tl[ii].id, start, stop);
}
fflush(fp_log);
fclose(fp_log);
Expand Down

0 comments on commit 7595728

Please sign in to comment.