GCViewer icon indicating copy to clipboard operation
GCViewer copied to clipboard

command line only mode

Open chewiebug opened this issue 12 years ago • 5 comments

GCViewer should be have a command line only mode so that no interaction is required to process a gc log file. This mode would allow the use of gcviewer in automated scripts. Add option to support export of graph as image.

chewiebug avatar Dec 28 '11 13:12 chewiebug

This mode should include the feature of exporting the graph (as image - GIF/PNG) in addition to CSV data.

nsureshn avatar Jan 18 '12 01:01 nsureshn

Command line mode should not not depend on any GUI component to run : That is should be able to run in a non interative session/shell. This would allow to use it in automated builds/test suites.

thierry-feltin avatar Apr 07 '12 05:04 thierry-feltin

I agree.

chewiebug avatar Apr 07 '12 20:04 chewiebug

I have a java class that takes a gc.log filename and prints some information (throughput, max used mem after gc, total gc'ed mem) on System.out using GCViewer classes. Here is my source code :


import com.tagtraum.perf.gcviewer.*;
import java.io.FileInputStream; 
import java.io.File;
import java.util.logging.Logger;
import java.util.logging.Level; 
import java.util.Locale;

public class GCLogStatistics {

    private final GCLogStatistics i = null; 
    private static final DataReaderFactory factory = new DataReaderFactory();

    public static void main (String args[]) {

        if (args == null || args.length != 1) { 
            System.out.println("Usage: GCLogStatistics gc.log");
            return; 
        }

        GCLogStatistics i = new GCLogStatistics(args[0]);
    }

    GCLogStatistics(String filename) {
        
        try {
            final File f = new File(filename);
            final FileInputStream in = new FileInputStream(f);
            final DataReader reader = factory.getDataReader(in);
            final GCModel model = reader.read();

            System.out.printf(Locale.US,"THROUGHPUT:%2.2f\n",model.getThroughput());
            System.out.println("MAXUSEDMEM:"+model.getPostFullGCUsedMemory().getMax()); 
            System.out.println("TOTALGCEDMEM:"+model.getFreedMemory()); 

        } catch (Exception e ) {
            System.err.println (e.toString ()); 
        }
    }
    
}

dleborgne avatar Jul 06 '12 09:07 dleborgne

Hi David,

Thank you for this sample. There is another user working on this issue (pbilstein). His approach extracts more information. When he releases his code I'll have to see how I can combine the two different approaches.

Regards, Jörg

chewiebug avatar Jul 09 '12 19:07 chewiebug