Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frame Performance Tool- jperf #1785

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions bin/trick-jperf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/perl

use FindBin qw($RealBin);
use lib ("$RealBin/../libexec/trick/pm", "$RealBin/../lib/trick/pm") ;
use launch_java ;

launch_java("JPERF", "JPerf") ;

2 changes: 2 additions & 0 deletions include/trick/FrameLog.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ namespace Trick {
/** Data to save for each timeline sample.\n */
struct timeline_t {
bool trick_job;
bool isEndOfFrame;
bool isTopOfFrame;
double id;
long long start;
long long stop;
Expand Down
6 changes: 6 additions & 0 deletions include/trick/JobData.hh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ namespace Trick {
/** Indicates if a scheduler is handling this job */
bool handled; /**< trick_units(--) */

/** Indicates whether this is an "top_of_frame" job. */
bool isTopOfFrame; /**< trick_units(--) */

/** Indicates whether this is an "end_of_frame" job. */
bool isEndOfFrame; /**< trick_units(--) */

/** The cycle time */
double cycle; /**< trick_units(s) */

Expand Down
16 changes: 16 additions & 0 deletions trick_source/java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,22 @@
<finalName>MM</finalName>
</configuration>
</execution>
<execution>

<id>jobperf</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>trick.jobperf.JobPerf</mainClass>
</transformer>
</transformers>
<finalName>JPerf</finalName>
</configuration>
</execution>

</executions>
</plugin>
Expand Down
27 changes: 27 additions & 0 deletions trick_source/java/src/main/java/trick/jobperf/FrameRecord.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package trick.jobperf;
import java.util.*;
/**
* Class FrameRecord represents the set of jobs that have been executed during a
* frame.
*/
public class FrameRecord {
public ArrayList<JobExecutionEvent> jobEvents;
public double start;
public double stop;
/**
* Constructor
*/
public FrameRecord() {
start = 0.0;
stop = 0.0;
jobEvents = new ArrayList<JobExecutionEvent>()

;
}
/**
* @return the stop time minus the start time.
*/
public double getDuration() {
return stop - start;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package trick.jobperf;

/**
* Class InvalidFrameBoundsExpection is an exception indicating
* that the user has specified an illegal range for the frames
* to be rendered.
*/
class InvalidFrameBoundsExpection extends Exception {
public InvalidFrameBoundsExpection(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package trick.jobperf;

import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.lang.Math;
import java.util.*;
import java.util.List;
import javax.swing.*;
import javax.swing.event.*;
import java.net.URL;


/**
* 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.
*/
class JobExecutionEvent {
public String id;
public boolean isEOF;
public boolean isTOF;
public double start;
public double stop;

/**
* @param identifier identifies the relavant Trick job.
* @param isTopOfFrame true if the job is a "top-of-frame" job, otherwise false.
* @param isEndOfFrame true if the job is a "end-of-frame" job, otherwise false.
* @param start_time the start time (seconds) of the identified job.
* @param stop_time the stop time (seconds) of the identified job.
*/
public JobExecutionEvent(String identifier, boolean isTopOfFrame, boolean isEndOfFrame, double start_time, double stop_time) {
id = identifier;
isEOF = isEndOfFrame;
isTOF = isTopOfFrame;
start = start_time;
stop = stop_time;
}
/**
* Create a String representation of an object of this class.
*/
@Override
public String toString() {
return ( "JobExecutionEvent: " + id + "," + start + "," + stop );
}
}
164 changes: 164 additions & 0 deletions trick_source/java/src/main/java/trick/jobperf/JobPerf.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
package trick.jobperf;

import java.awt.*;
import java.io.*;
import java.util.*;
import javax.swing.*;

/**
* Capabilites That Need To Be Added
* - a way to filter the data to be within a user specified sub time period
* within the data set.
*/

/**
* Class JobPerf is an application that renders time-line data from a Trick based
simulation. It also generates run-time statistics reports for the simulation
jobs. It can be run with or without a GUI.
*/
public class JobPerf {
ArrayList<JobExecutionEvent> jobExecEvtList;
JobStats jobStats;

/**
* Constructor
* @param args the command line arguments.
*/
public JobPerf( String[] args ) {
TraceViewWindow traceViewWindow;
boolean interactive = true;
boolean printReport = false;
JobStats.SortCriterion sortOrder = JobStats.SortCriterion.MEAN;
String fileName = "in.csv";

int ii = 0;
while (ii < args.length) {
switch (args[ii]) {
case "-h" :
case "--help" : {
printHelpText();
System.exit(0);
} break;
case "-x" :
case "--nogui" : {
interactive = false;
} break;
case "-p" :
case "--report" : {
printReport = true;
} break;
case "-s0" :
case "--sort=id" : {
sortOrder = JobStats.SortCriterion.ID;
} break;
case "-s1" :
case "--sort=mean" : {
sortOrder = JobStats.SortCriterion.MEAN;
} break;
case "-s2" :
case "--sort=stddev" : {
sortOrder = JobStats.SortCriterion.STDDEV;
} break;
case "-s3" :
case "--sort=max" : {
sortOrder = JobStats.SortCriterion.MAX;
} break;
case "-s4" :
case "--sort=min" : {
sortOrder = JobStats.SortCriterion.MIN;
} break;
default : {
fileName = args[ii];
} break;
} //switch
++ii;
} // while

jobExecEvtList = getJobExecutionEventList(fileName);
jobStats = new JobStats(jobExecEvtList);
if (printReport) {
if (sortOrder == JobStats.SortCriterion.ID ) jobStats.SortByID();
if (sortOrder == JobStats.SortCriterion.MEAN ) jobStats.SortByMeanValue();
if (sortOrder == JobStats.SortCriterion.STDDEV ) jobStats.SortByStdDev();
if (sortOrder == JobStats.SortCriterion.MAX ) jobStats.SortByMaxValue();
if (sortOrder == JobStats.SortCriterion.MIN ) jobStats.SortByMinValue();
jobStats.write();
}
if (interactive) {
traceViewWindow = new TraceViewWindow(jobExecEvtList);
}
}

/**
* Print the usage instructions to the terminal.
*/
private static void printHelpText() {
System.out.println(
"----------------------------------------------------------------------\n"
+ "usage: trick-jperf [options] <file-name>\n\n"
+ "options: \n"
+ "-h, --help\n"
+ " Print this help text and exit.\n"
+ "-x, --nogui\n"
+ " Don't run as a GUI application. Command line only.\n"
+ "-p, --report\n"
+ " Write sorted job statics report to the terminal.\n"
+ "-s0, --sort=id\n"
+ " Sort job statistics by identifier.\n"
+ "-s1, --sort=mean [default]\n"
+ " Sort job statistics by mean duration.\n"
+ "-s2, --sort=stddev\n"
+ " Sort job statistics by standard deviation of duration.\n"
+ "-s3, --sort=min\n"
+ " Sort job statistics by minimum duration.\n"
+ "-s4, --sort=max\n"
+ " Sort job statistics by maximum duration.\n"
+ "----------------------------------------------------------------------\n"
);
}

/**
* Read the timeline file, resulting in a ArrayList<JobExecutionEvent>.
*/
private ArrayList<JobExecutionEvent> getJobExecutionEventList( String fileName ) {
String line;
String field[];

ArrayList<JobExecutionEvent> jobExecEvtList = new ArrayList<JobExecutionEvent>();
try {
BufferedReader in = new BufferedReader( new FileReader(fileName) );

// Strip the header off the CSV file.
line = in.readLine();
while( (line = in.readLine()) !=null) {
field = line.split(",");
String id = field[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]);

if (start < stop) {
JobExecutionEvent evt = new JobExecutionEvent(id, isTOF, isEOF, start, stop);
jobExecEvtList.add( evt);
}
}
} catch ( java.io.FileNotFoundException e ) {
System.out.println("File \"" + fileName + "\" not found.\n");
System.exit(0);
} catch ( java.io.IOException e ) {
System.out.println("IO Exception.\n");
System.exit(0);
}
return jobExecEvtList;
}

/**
* Entry point for the Java application.
*/
public static void main(String[] args) {
JobPerf jobPerf = new JobPerf( args );
}
}
Loading
Loading