From: jjenista Date: Tue, 2 Nov 2010 02:56:14 +0000 (+0000) Subject: have coreprof plot events X-Git-Url: http://plrg.eecs.uci.edu/git/?p=IRC.git;a=commitdiff_plain;h=8671558ed3915d63d2d5d9aee8e3999e544035a8 have coreprof plot events --- diff --git a/Robust/CoreProf/Trace.java b/Robust/CoreProf/Trace.java index 0d69195e..6665d0b1 100644 --- a/Robust/CoreProf/Trace.java +++ b/Robust/CoreProf/Trace.java @@ -71,8 +71,8 @@ public class Trace { public static void main( String args[] ) { if( args.length < 2 || args.length > 3 ) { - System.out.println( "usage: [-2txt] " ); - System.out.println( "The -2txt option will take the raw binary events and spit\n"+ + System.out.println( "usage: [-2txt]\n"+ + "\nThe -2txt option will take the raw binary events and spit\n"+ "out every event as text in events.txt, useful for debugging\n"+ "event mis-matches." ); System.exit( 0 ); @@ -99,11 +99,17 @@ public class Trace { boolean convert2txt; BufferedWriter txtStream; + boolean convert2plot; + BufferedWriter bwPlot; + long tSysZero; + Hashtable plottedEvents; + public Trace( boolean c2txt, String inFile, String outFile ) { - convert2txt = c2txt; + convert2txt = c2txt; + convert2plot = true; openInputStreams( inFile ); @@ -114,6 +120,10 @@ public class Trace { } printStats( outFile ); + + if( convert2plot ) { + printPlotCmd(); + } } @@ -173,10 +183,6 @@ public class Trace { offset = readHeader( bis ); bis.close(); - if( convert2txt ) { - txtStream = new BufferedWriter( new FileWriter( "events.txt" ) ); - } - } catch( Exception e ) { e.printStackTrace(); System.exit( -1 ); @@ -235,6 +241,8 @@ public class Trace { if( convert2txt ) { try { + txtStream = new BufferedWriter( new FileWriter( "events.txt" ) ); + txtStream.write( "\n\n\n\n" ); txtStream.write( "*************************************************\n" ); txtStream.write( "** Thread "+tNum+"\n" ); @@ -245,6 +253,18 @@ public class Trace { } } + if( convert2plot ) { + try { + bwPlot = new BufferedWriter( new FileWriter( "plot-t"+tNum+".dat" ) ); + } catch( IOException e ) { + e.printStackTrace(); + System.exit( -1 ); + } + + plottedEvents = new Hashtable(); + } + + ThreadData tdata = threadData[tNum]; tdata.stackDepth = 0; long timeStamp = 0; @@ -279,7 +299,11 @@ public class Trace { switch( eventType ) { case CP_EVENTTYPE_BEGIN: { - pushEvent( tdata, eventID, timeStamp ); + if( eventID == CP_EVENTID_MAIN ) { + tSysZero = timeStamp; + } + + pushEvent( tdata, eventID, timeStamp ); } break; case CP_EVENTTYPE_END: { @@ -287,6 +311,10 @@ public class Trace { } break; } + + if( convert2plot ) { + addPointToPlot( timeStamp, eventID ); + } } System.out.println( "" ); @@ -307,6 +335,16 @@ public class Trace { --tdata.stackDepth; } + + + if( convert2plot ) { + try { + bwPlot.close(); + } catch( IOException e ) { + e.printStackTrace(); + System.exit( -1 ); + } + } } @@ -436,6 +474,24 @@ public class Trace { } + public void addPointToPlot( long timeStamp, int eventID ) { + + if( !plottedEvents.containsKey( eventID ) ) { + plottedEvents.put( eventID, plottedEvents.size() ); + } + + try { + bwPlot.write( (timeStamp - tSysZero)+" "+ + plottedEvents.get( eventID )+" "+ + getEventName( eventID )+"\n" + ); + } catch( IOException e ) { + e.printStackTrace(); + System.exit( -1 ); + } + } + + public void printStats( String filename ) { @@ -532,4 +588,29 @@ public class Trace { printEventSummary( bw, esChild, depth + 1 ); } } + + + public void printPlotCmd() { + try { + BufferedWriter bw = + new BufferedWriter( new FileWriter( "plot.cmd" ) ); + + bw.write( "set ytics\n" ); + bw.write( "plot \\\n" ); + + for( int i = 0; i < numThreads; ++i ) { + bw.write( "\"plot-t"+i+".dat\" using 1:2:yticlabels(3) "+ + "title 't"+i+"' with linespoints" ); + if( i != numThreads - 1 ) { + bw.write( ", \\" ); + } + bw.write( "\n" ); + } + + bw.close(); + } catch( IOException e ) { + e.printStackTrace(); + System.exit( -1 ); + } + } } diff --git a/Robust/CoreProf/makefile b/Robust/CoreProf/makefile index 79ecaa14..e534b7c6 100644 --- a/Robust/CoreProf/makefile +++ b/Robust/CoreProf/makefile @@ -6,6 +6,10 @@ run: java -ea Trace coreprof.dat trace.out +plot: coreprof.dat + gnuplot plot.cmd + + clean: rm -f *.class rm -f *~