From 75957282167538343ed3adad7685cbe1b2b28a33 Mon Sep 17 00:00:00 2001 From: "John M. Penn" Date: Tue, 28 Jan 2025 15:28:04 -0600 Subject: [PATCH] Refactor timeline log and improve frame boundary determination. --- .../java/trick/jobperf/FrameViewCanvas.java | 12 ++++++--- .../java/trick/jobperf/JobExecutionEvent.java | 8 +++--- .../src/main/java/trick/jobperf/JobPerf.java | 26 ++++++++++--------- .../trick/jobperf/JobSpecificationMap.java | 4 +-- .../java/trick/jobperf/TraceViewCanvas.java | 5 +++- .../sim_services/FrameLog/FrameLog.cpp | 7 ++--- 6 files changed, 35 insertions(+), 27 deletions(-) diff --git a/trick_source/java/src/main/java/trick/jobperf/FrameViewCanvas.java b/trick_source/java/src/main/java/trick/jobperf/FrameViewCanvas.java index 8ebdcebb..7dd3162e 100644 --- a/trick_source/java/src/main/java/trick/jobperf/FrameViewCanvas.java +++ b/trick_source/java/src/main/java/trick/jobperf/FrameViewCanvas.java @@ -58,16 +58,22 @@ public class FrameViewCanvas extends JPanel { 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(); } diff --git a/trick_source/java/src/main/java/trick/jobperf/JobExecutionEvent.java b/trick_source/java/src/main/java/trick/jobperf/JobExecutionEvent.java index af93f2ba..ea764816 100644 --- a/trick_source/java/src/main/java/trick/jobperf/JobExecutionEvent.java +++ b/trick_source/java/src/main/java/trick/jobperf/JobExecutionEvent.java @@ -15,13 +15,13 @@ import java.net.URL; * Class JobExecutionEvent represents one execution/run of a Trick job. * identifies the job. and specify the * clock times at which the job started and finished. -* and indicate whether the job was run as -* an "end-of-frame", or a "top-of-frame" job. +* 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; @@ -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; diff --git a/trick_source/java/src/main/java/trick/jobperf/JobPerf.java b/trick_source/java/src/main/java/trick/jobperf/JobPerf.java index b9365a43..9fed2084 100644 --- a/trick_source/java/src/main/java/trick/jobperf/JobPerf.java +++ b/trick_source/java/src/main/java/trick/jobperf/JobPerf.java @@ -74,7 +74,6 @@ public class JobPerf { 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" ); @@ -103,7 +102,7 @@ public class JobPerf { System.exit(0); } - jobExecEvtList = getJobExecutionEventList(timeLineFileName); + jobExecEvtList = getJobExecutionEventList(timeLineFileName, jobSpecificationMap); if (printReport) { jobStats = new JobStats(jobExecEvtList); @@ -150,7 +149,8 @@ public class JobPerf { /** * Read the timeline file, resulting in a ArrayList. */ - private ArrayList getJobExecutionEventList( String fileName ) { + private ArrayList getJobExecutionEventList( String fileName, + JobSpecificationMap jobSpecificationMap ) { String line; String field[]; @@ -162,16 +162,18 @@ public class JobPerf { 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*$",""); - 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]); + String id = field[0].trim(); + JobSpecification jobSpec = jobSpecificationMap.getJobSpecification(id); + boolean isTOF = false; + boolean isEOF = false; + 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); diff --git a/trick_source/java/src/main/java/trick/jobperf/JobSpecificationMap.java b/trick_source/java/src/main/java/trick/jobperf/JobSpecificationMap.java index d5f7b6d1..af6996bd 100644 --- a/trick_source/java/src/main/java/trick/jobperf/JobSpecificationMap.java +++ b/trick_source/java/src/main/java/trick/jobperf/JobSpecificationMap.java @@ -27,10 +27,10 @@ public class JobSpecificationMap { 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); } } } diff --git a/trick_source/java/src/main/java/trick/jobperf/TraceViewCanvas.java b/trick_source/java/src/main/java/trick/jobperf/TraceViewCanvas.java index 9552ad82..df24b559 100644 --- a/trick_source/java/src/main/java/trick/jobperf/TraceViewCanvas.java +++ b/trick_source/java/src/main/java/trick/jobperf/TraceViewCanvas.java @@ -87,12 +87,13 @@ public class TraceViewCanvas extends JPanel { try { boolean wasTOF = false; + boolean wasEOF = false; List frameList = new ArrayList(); 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(); @@ -105,6 +106,8 @@ public class TraceViewCanvas extends JPanel { frameRecord.jobEvents.add(jobExec); wasTOF = jobExec.isTOF; + wasEOF = jobExec.isEOF; + idToColorMap.addKey(jobExec.id); } diff --git a/trick_source/sim_services/FrameLog/FrameLog.cpp b/trick_source/sim_services/FrameLog/FrameLog.cpp index f6980729..131fc9ba 100644 --- a/trick_source/sim_services/FrameLog/FrameLog.cpp +++ b/trick_source/sim_services/FrameLog/FrameLog.cpp @@ -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);