private static short depth_max;
public static final void main( String[] args )
throws IOException
{
InputLog slog_ins;
CategoryMap objdefs;
TreeTrunk treetrunk;
TreeNode treeroot;
TimeBoundingBox timeframe_old, timeframe;
short depth;
String err_msg;
parseCmdLineArgs( args );
slog_ins = new InputLog( in_slog2filename );
if ( slog_ins == null ) {
System.err.println( "Null input logfile!" );
System.exit( 1 );
}
if ( ! slog_ins.isSLOG2() ) {
System.err.println( in_slog2filename + " 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 );
long time1, time2;
StringBuffer timing_str;
// 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_slog2filename + " "
+ "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 data_file = new File( in_datafilename );
TimeBoxList tbox_list = new TimeBoxList( data_file );
Iterator itr_times = tbox_list.iterator();
timeframe = timeframe_root;
if ( itr_times.hasNext() )
timeframe = (TimeBoundingBox) itr_times.next();
else {
System.out.println( "No more timeframe in datafile "
+ in_datafilename + ". Exiting..." );
System.exit( 0 );
}
System.out.println( "# Srolling Duration = "
+ timeframe.getDuration() );
// Append xmgrace description of the graph
StringBuffer xmgrace_strbuf = new StringBuffer();
xmgrace_strbuf.append( "@with g0\n" );
xmgrace_strbuf.append( "@ title \"" + in_slog2filename + "\"\n" );
xmgrace_strbuf.append( "@ legend 0.4, 0.8\n" );
xmgrace_strbuf.append( "@ xaxis label " );
xmgrace_strbuf.append( "\"Time location in logfile (sec).\"\n" );
xmgrace_strbuf.append( "@ yaxis label " );
xmgrace_strbuf.append( "\"Time taken per scroll (msec).\"\n" );
xmgrace_strbuf.append( "@ s0 symbol 1\n" );
xmgrace_strbuf.append( "@ s0 symbol size 0.25\n" );
xmgrace_strbuf.append( "@ s0 line type 0\n" );
xmgrace_strbuf.append( "@ s0 legend " );
xmgrace_strbuf.append( "\"Duration of each scroll = "
+ (float)timeframe.getDuration() + " sec.\"\n" );
xmgrace_strbuf.append( "@target G0.S0\n" );
xmgrace_strbuf.append( "@type xy\n" );
System.out.println( xmgrace_strbuf.toString() );
timing_str = new StringBuffer();
// timing_str.append( timeframe + " @ d = " + depth + ": " );
timing_str.append( timeframe.getEarliestTime() + " " );
time1 = System.nanoTime();
// Grow to a fixed size first
// depth = depth_max;
depth = 0;
treetrunk.growInTreeWindow( treeroot, depth, timeframe );
switch (print_opt) {
case PRINT_ALL :
System.out.println( treetrunk.toString( timeframe ) );
break;
case PRINT_STUB :
System.out.println( treetrunk.toStubString() );
break;
case PRINT_NONE :
default :
}
timeframe_old = timeframe;
time2 = System.nanoTime();
// timing_str.append( (1.0e-6 * (time2 - time1)) + " msec." );
timing_str.append( (1.0e-6 * (time2 - time1)) );
System.out.println( timing_str.toString() );
// Navigate the slog2 tree
while ( itr_times.hasNext() ) {
timeframe = (TimeBoundingBox) itr_times.next();
timing_str = new StringBuffer();
// timing_str.append( timeframe + " @ d = " + depth + ": " );
timing_str.append( timeframe.getEarliestTime() + " " );
time1 = System.nanoTime();
if ( treetrunk.updateTimeWindow( timeframe_old, timeframe )
> TreeTrunk.TIMEBOX_EQUAL ) {
switch (print_opt) {
case PRINT_ALL :
// System.out.println(
// treetrunk.toFloorString( timeframe ) );
System.out.println( treetrunk.toString( timeframe ) );
// System.out.println( treetrunk.toString() );
break;
case PRINT_STUB :
System.out.println( treetrunk.toStubString() );
break;
case PRINT_NONE :
default :
}
timeframe_old = timeframe;
}
time2 = System.nanoTime();
// timing_str.append( (1.0e-6 * (time2 - time1)) + " msec." );
timing_str.append( (1.0e-6 * (time2 - time1)) );
System.out.println( timing_str.toString() );
}
slog_ins.close();
}