Commit d77ef5f7 authored by chan's avatar chan
Browse files

Checked in the performance measurement code for slog2 and clog2.

parent d17d6170
......@@ -66,7 +66,7 @@ public class TimeBoundingBox implements DataIO
}
}
private TimeBoundingBox( double starttime, double finaltime )
public TimeBoundingBox( double starttime, double finaltime )
{
earliest_time = starttime;
latest_time = finaltime;
......@@ -337,10 +337,12 @@ public class TimeBoundingBox implements DataIO
return ( "TimeBBox( - )" );
*/
return ( "TimeBBox(" + earliest_time + "," + latest_time + ")" );
/*
}
public String toShortString()
{
return ( "TimeBBox(" + (float) earliest_time
+ "," + (float) latest_time + ")" );
*/
}
......
......@@ -21,6 +21,7 @@ RM = @RM@
TARGET = $(libbuild_dir)/clog2TOdrawable.jar
TARGET1 = $(libbuild_dir)/clog2TOdrawable_1pass.jar
TARGET2 = $(libbuild_dir)/clog2TOdrawable_2pass.jar
TARGET3 = $(libbuild_dir)/clog2perftest.jar
PACKAGE = logformat.clog2TOdrawable
SRC = ColorNameMap.java ObjDef.java \
Obj_Event.java Obj_Arrow.java Obj_State.java ObjMethod.java \
......@@ -31,6 +32,10 @@ SRC = ColorNameMap.java ObjDef.java \
OBJ = $(SRC:.java=.class)
TS_SRC = PerfTest.java
TS_OBJ = $(TS_SRC:.java=.class)
.SUFFIXES: .java .class .jar
# CLASSDIR is where classfiles are located, all counted from the top
......@@ -47,6 +52,8 @@ JCFLAGS = -sourcepath @JPATH_START@$(SRCDIR)@JPATH_FINAL@ -classpath @JPATH_STAR
# ALL: $(TARGET) $(TARGET1) $(TARGET2)
ALL: $(TARGET)
test: $(TARGET3)
$(TARGET): $(OBJ)
cd $(CLASSDIR) && \
$(RM) $(PACKAGE).manifest && \
......@@ -83,6 +90,18 @@ $(TARGET2): $(OBJ)
done ; \
$(JAR) $(JARFLAGS)uf $${jarfile} jumpshot.colors
$(TARGET3): $(OBJ) $(TS_OBJ)
cd $(CLASSDIR) && \
$(RM) $(PACKAGE).manifest && \
echo "Main-Class: $(PACKAGE).PerfTest" > $(PACKAGE).manifest ; \
jarfile=@JPATH_START@$@@JPATH_FINAL@ ; \
$(JAR) $(JARFLAGS)cfm $${jarfile} $(PACKAGE).manifest ; \
for dir in base/io/ logformat/clog2/ base/drawable/ $(PKGDIR)/ ; do \
classdir_prefix=@JPATH_START@$${dir}@JPATH_FINAL@ ; \
$(JAR) $(JARFLAGS)uf $${jarfile} $${classdir_prefix}*.class ; \
done ; \
$(JAR) $(JARFLAGS)uf $${jarfile} jumpshot.colors
clean:
cd $(CLASSDIR) && \
$(RM) $(PACKAGE).manifest $(PKGDIR)/*.class
......
/*
* (C) 2001 by Argonne National Laboratory
* See COPYRIGHT in top-level directory.
*/
/*
* @author Anthony Chan
*/
package logformat.clog2TOdrawable;
import java.util.*;
import base.drawable.*;
public class PerfTest
{
public static final void main( String args[] )
{
String filename;
InputLog dobj_ins;
List objdefs; // Primitive def'n
Map shadefs; // Shadow def'n
Kind next_kind;
Category objdef;
Topology topo;
Primitive drawobj;
long Nobjs;
if ( args.length != 1 ) {
System.err.println( "This program needs 1 argument: filename." );
System.err.println( "\tUsage: clog2TOdrawable.PerfTimer filename" );
System.exit( 0 );
}
filename = args[ 0 ];
objdefs = new ArrayList();
shadefs = new HashMap();
Nobjs = 0;
Date time1, time2;
dobj_ins = new InputLog( filename );
time1 = new Date();
while ( ( next_kind = dobj_ins.peekNextKind() ) != Kind.EOF ) {
if ( next_kind == Kind.TOPOLOGY ) {
topo = dobj_ins.getNextTopology();
objdef = Category.getShadowCategory( topo );
objdefs.add( objdef );
shadefs.put( topo, objdef );
}
if ( next_kind == Kind.YCOORDMAP ) {
// invoke InputLog().getNextYCoordMap() to get stream moving
dobj_ins.getNextYCoordMap();
}
if ( next_kind == Kind.CATEGORY ) {
objdef = dobj_ins.getNextCategory();
objdefs.add( objdef );
}
if ( next_kind == Kind.PRIMITIVE ) {
drawobj = dobj_ins.getNextPrimitive();
Nobjs++;
// System.out.println( vport_Nobjs + ", " + drawobj );
}
}
time2 = new Date();
dobj_ins.close();
/*
System.err.println( "\n\t Shadow Category Definitions : " );
Iterator shadefs_itr = shadefs.entrySet().iterator();
while ( shadefs_itr.hasNext() )
System.err.println( shadefs_itr.next() );
System.err.println( "\n\t Primitive Category Definitions : " );
Iterator objdefs_itr = objdefs.iterator();
while ( objdefs_itr.hasNext() ) {
objdef = (Category) objdefs_itr.next();
System.err.println( objdef.toString() );
}
*/
System.err.println( "\n" );
System.err.println( "Total Number of Primitives read = "
+ Nobjs );
System.err.println( "Total ByteSize of the logfile read = "
+ dobj_ins.getTotalBytesRead() );
// System.err.println( "time1 = " + time1 + ", " + time1.getTime() );
// System.err.println( "time2 = " + time2 + ", " + time2.getTime() );
// System.err.println( "time3 = " + time3 + ", " + time3.getTime() );
System.err.println( "timeElapsed between 1 & 2 = "
+ ( time2.getTime() - time1.getTime() ) + " msec" );
}
}
......@@ -48,6 +48,10 @@ public class Print
objdefs.add( objdef );
shadefs.put( topo, objdef );
}
if ( next_kind == Kind.YCOORDMAP ) {
// invoke InputLog().getNextYCoordMap() to get stream moving
dobj_ins.getNextYCoordMap();
}
if ( next_kind == Kind.CATEGORY ) {
objdef = dobj_ins.getNextCategory();
objdefs.add( objdef );
......
......@@ -21,6 +21,8 @@ RM = @RM@
TARGET0 = $(libbuild_dir)/slog2printrecur.jar
TARGET1 = $(libbuild_dir)/slog2printserial.jar
TARGET2 = $(libbuild_dir)/slog2navigator.jar
TARGET3 = $(libbuild_dir)/slog2perfdata.jar
TARGET4 = $(libbuild_dir)/slog2perftest.jar
PACKAGE = logformat.slog2.input
SRC = IteratorOfGroupObjects.java TreeNode.java InputLog.java \
BufStub.java TreeFloor.java \
......@@ -29,6 +31,10 @@ SRC = IteratorOfGroupObjects.java TreeNode.java InputLog.java \
OBJ = $(SRC:.java=.class)
TS_SRC = PerfData.java PerfTest.java
TS_OBJ = $(TS_SRC:.java=.class)
.SUFFIXES: .java .class .jar
# CLASSDIR is where classfiles are located, all counted from the top
......@@ -44,6 +50,8 @@ JCFLAGS = -sourcepath @JPATH_START@$(SRCDIR)@JPATH_FINAL@ -classpath @JPATH_STAR
ALL: $(TARGET0) $(TARGET1) $(TARGET2)
test: $(TARGET3) $(TARGET4)
$(TARGET0): $(OBJ)
cd $(CLASSDIR) && \
$(RM) $(PACKAGE).manifest && \
......@@ -77,12 +85,34 @@ $(TARGET2): $(OBJ)
$(JAR) $(JARFLAGS)uf $${jarfile} $${classdir_prefix}*.class ; \
done
$(TARGET3): $(OBJ) $(TS_OBJ)
cd $(CLASSDIR) && \
$(RM) $(PACKAGE).manifest && \
echo "Main-Class: $(PACKAGE).PerfData" > $(PACKAGE).manifest ; \
jarfile=@JPATH_START@$@@JPATH_FINAL@ ; \
$(JAR) $(JARFLAGS)cfm $${jarfile} $(PACKAGE).manifest ; \
for dir in base/io/ base/drawable/ logformat/slog2/ $(PKGDIR)/ ; do \
classdir_prefix=@JPATH_START@$${dir}@JPATH_FINAL@ ; \
$(JAR) $(JARFLAGS)uf $${jarfile} $${classdir_prefix}*.class ; \
done
$(TARGET4): $(OBJ) $(TS_OBJ)
cd $(CLASSDIR) && \
$(RM) $(PACKAGE).manifest && \
echo "Main-Class: $(PACKAGE).PerfTest" > $(PACKAGE).manifest ; \
jarfile=@JPATH_START@$@@JPATH_FINAL@ ; \
$(JAR) $(JARFLAGS)cfm $${jarfile} $(PACKAGE).manifest ; \
for dir in base/io/ base/drawable/ logformat/slog2/ $(PKGDIR)/ ; do \
classdir_prefix=@JPATH_START@$${dir}@JPATH_FINAL@ ; \
$(JAR) $(JARFLAGS)uf $${jarfile} $${classdir_prefix}*.class ; \
done
clean:
cd $(CLASSDIR) && \
$(RM) $(PACKAGE).manifest $(PKGDIR)/*.class
rmlib:
$(RM) $(TARGET0) $(TARGET1) $(TARGET2)
$(RM) $(TARGET0) $(TARGET1) $(TARGET2) $(TARGET3)
realclean: clean rmlib
......
/*
* (C) 2001 by Argonne National Laboratory
* See COPYRIGHT in top-level directory.
*/
/*
* @author Anthony Chan
*/
package logformat.slog2.input;
import java.util.Iterator;
import java.io.File;
import java.io.FileOutputStream;
import java.io.DataOutputStream;
import base.drawable.*;
import logformat.slog2.*;
import logformat.slog2.input.InputLog;
public class PerfData
{
private static boolean isVerbose = false;
private static TimeBoundingBox timeframe_root = null;
private static String in_filename;
private static short depth_max;
public static final void main( String[] args )
throws java.io.IOException
{
InputLog slog_ins;
CategoryMap objdefs;
TreeTrunk treetrunk;
TreeNode treeroot;
TimeBoundingBox timeframe;
String err_msg;
parseCmdLineArgs( args );
slog_ins = new InputLog( in_filename );
if ( slog_ins == null ) {
System.err.println( "Null input logfile!" );
System.exit( 1 );
}
if ( ! slog_ins.isSLOG2() ) {
System.err.println( in_filename + " is NOT SLOG-2 file!." );
System.exit( 1 );
}
if ( (err_msg = slog_ins.getCompatibleHeader()) != null ) {
System.err.print( err_msg );
InputLog.stdoutConfirmation();
}
slog_ins.initialize();
// System.out.println( slog_ins );
// Initialize the TreeTrunk with same order as in Jumpshot.
treetrunk = new TreeTrunk( slog_ins, Drawable.INCRE_STARTTIME_ORDER );
treetrunk.setDebuggingEnabled( isVerbose );
treetrunk.initFromTreeTop();
treeroot = treetrunk.getTreeRoot();
if ( treeroot == null ) {
System.out.println( "SLOG-2 file, " + in_filename + " "
+ "contains no drawables" );
slog_ins.close();
System.exit( 0 );
}
timeframe_root = new TimeBoundingBox( treeroot );
depth_max = treeroot.getTreeNodeID().depth;
System.out.println( "# TimeWindow = " + timeframe_root
+ " @ dmax = " + depth_max );
File out_file;
FileOutputStream out_fos;
DataOutputStream out_dos;
Iterator itr_times;
System.out.println( "**** Foreward ****" );
out_file = new File( append_name( in_filename, "_fscroll.dat" ) );
out_fos = new FileOutputStream( out_file );
out_dos = new DataOutputStream( out_fos );
itr_times = new ItrOfForeScrollTimes( timeframe_root );
while ( itr_times.hasNext() ) {
timeframe = (TimeBoundingBox) itr_times.next();
timeframe.writeObject( out_dos );
System.out.println( timeframe );
}
out_fos.close();
System.out.println( "**** Backward ****" );
out_file = new File( append_name( in_filename, "_bscroll.dat" ) );
out_fos = new FileOutputStream( out_file );
out_dos = new DataOutputStream( out_fos );
itr_times = new ItrOfBackScrollTimes( timeframe_root );
while ( itr_times.hasNext() ) {
timeframe = (TimeBoundingBox) itr_times.next();
timeframe.writeObject( out_dos );
System.out.println( timeframe );
}
out_fos.close();
System.out.println( "**** Alternate Zoom ****" );
out_file = new File( append_name( in_filename, "_altzoom.dat" ) );
out_fos = new FileOutputStream( out_file );
out_dos = new DataOutputStream( out_fos );
itr_times = new ItrOfAltZoomTimes( timeframe_root );
while ( itr_times.hasNext() ) {
timeframe = (TimeBoundingBox) itr_times.next();
timeframe.writeObject( out_dos );
System.out.println( timeframe );
}
out_fos.close();
slog_ins.close();
}
private static double zoom_ftr = 2.0d;
private static short getZoomDepth()
{
short depth_zoom;
if ( depth_max >= 3 ) {
depth_zoom = depth_max;
depth_zoom -= 3;
}
else
depth_zoom = 0;
return depth_zoom;
}
private static class ItrOfForeScrollTimes implements Iterator
{
private TimeBoundingBox root_times = null;
private TimeBoundingBox next_times = null;
public ItrOfForeScrollTimes( final TimeBoundingBox endtimes )
{
root_times = new TimeBoundingBox( endtimes );
/* Set initial next_times = middle of root_times */
short depth0 = getZoomDepth();
double ctr_zoom = ( root_times.getEarliestTime()
+ root_times.getLatestTime() )
/ 2.0d;
double zoom_width = Math.pow( zoom_ftr, (double) depth0 );
double ctr_span = root_times.getDuration() / 2.0d
/ (zoom_width + 1.0d);
next_times = new TimeBoundingBox( ctr_zoom - ctr_span,
ctr_zoom + ctr_span );
}
public boolean hasNext()
{
return root_times.covers( next_times );
}
public Object next()
{
/* next_times = prev_times */
TimeBoundingBox prev_times = new TimeBoundingBox( next_times );
/* next_times = prev_times + delta_times */
next_times.setEarliestTime( prev_times.getLatestTime() );
next_times.setLatestFromEarliest( prev_times.getDuration() );
if ( root_times.overlaps( prev_times ) )
return prev_times;
else
return null;
}
public void remove() {}
}
private static class ItrOfBackScrollTimes implements Iterator
{
private TimeBoundingBox root_times = null;
private TimeBoundingBox next_times = null;
public ItrOfBackScrollTimes( final TimeBoundingBox endtimes )
{
root_times = new TimeBoundingBox( endtimes );
/* Set initial next_times = middle of root_times */
short depth0 = getZoomDepth();
double ctr_zoom = ( root_times.getEarliestTime()
+ root_times.getLatestTime() )
/ 2.0d;
double zoom_width = Math.pow( zoom_ftr, (double) depth0 );
double ctr_span = root_times.getDuration() / 2.0d
/ (zoom_width + 1.0d);
next_times = new TimeBoundingBox( ctr_zoom - ctr_span,
ctr_zoom + ctr_span );
}
public boolean hasNext()
{
return root_times.covers( next_times );
}
public Object next()
{
/* next_times = prev_times */
TimeBoundingBox prev_times = new TimeBoundingBox( next_times );
/* next_times = prev_times - delta_times */
next_times.setLatestTime( prev_times.getEarliestTime() );
next_times.setEarliestFromLatest( prev_times.getDuration() );
if ( root_times.overlaps( prev_times ) )
return prev_times;
else
return null;
}
public void remove() {}
}
private static class ItrOfAltZoomTimes implements Iterator
{
private TimeBoundingBox root_times = null;
private TimeBoundingBox next_times = null;
private double ctr_zoom;
private double ctr_span;
private double off_span;
private int isign;
private int count;
private int max_count;
public ItrOfAltZoomTimes( final TimeBoundingBox endtimes )
{
root_times = new TimeBoundingBox( endtimes );
/* Set initial next_times = middle of root_times */
short depth0 = getZoomDepth();
double zoom_width = Math.pow( zoom_ftr, (double) depth0 );
ctr_zoom = ( root_times.getEarliestTime()
+ root_times.getLatestTime() )
/ 2.0d;
ctr_span = root_times.getDuration() / 2.0d
/ (zoom_width + 1.0d);
next_times = new TimeBoundingBox( ctr_zoom - ctr_span,
ctr_zoom + ctr_span );
off_span = 0.0;
count = 0;
isign = 1;
max_count = 10;
}
public boolean hasNext()
{
return count < max_count && root_times.covers( next_times );
}
public Object next()
{
double off_zoom;
/* next_times = prev_times */
TimeBoundingBox prev_times = next_times;
/* next_times = prev_times +/- N * delta_times */
isign *= -1;
if ( isign < 0 )
off_span += 4 * ctr_span;
off_zoom = ctr_zoom + off_span * isign;
next_times = new TimeBoundingBox( off_zoom - ctr_span,
off_zoom + ctr_span );
if ( root_times.overlaps( prev_times ) )
return prev_times;
else
return null;
}
public void remove() {}
}
private static String help_msg = "Usage: java slog2.input.PerfTimer "
+ "[options] slog2_filename.\n"
+ "Options: \n"
+ "\t [-h|-help|--help] "
+ " Display this message.\n";
private static void parseCmdLineArgs( String argv[] )
{
String arg_str;
StringBuffer err_msg = new StringBuffer();
int idx = 0;
while ( idx < argv.length ) {
if ( argv[ idx ].startsWith( "-" ) ) {
if ( argv[ idx ].equals( "-h" )
|| argv[ idx ].equals( "-help" )
|| argv[ idx ].equals( "--help" ) ) {
System.out.println( help_msg );
System.out.flush();
System.exit( 0 );
}
else {
System.err.println( "Unrecognized option, "
+ argv[ idx ] + ", at "
+ indexOrderStr( idx+1 )
+ " command line argument" );
System.out.flush();
System.exit( 1 );
}
}
else {
in_filename = argv[ idx ];
idx++;
}
}
if ( in_filename == null ) {
System.err.println( "The Program needs a SLOG-2 filename as "
+ "a command line argument." );
System.err.println( help_msg );
System.exit( 1 );
}
}
private static String indexOrderStr( int idx )
{
switch (idx) {
case 1 : return Integer.toString( idx ) + "st";
case 2 : return Integer.toString( idx ) + "nd";
case 3 : return Integer.toString( idx ) + "rd";
default : return Integer.toString( idx ) + "th";
}
}
private static String append_name( String in_name, String add_name )
{
int loc_idx = in_name.lastIndexOf( ".slog2" );
if ( loc_idx > 0 )
return in_name.substring( 0, loc_idx ) + add_name;
else
return in_name + add_name;
}
}
/*
* (C) 2001 by Argonne National Laboratory
* See COPYRIGHT in top-level directory.