Skip to content

Command Line report generator #26

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

Closed
wants to merge 2 commits into from
Closed
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
6 changes: 5 additions & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GCViewer 1.31
GCViewer 1.31 fork with cmdline interface
=============

GCViewer is a little tool that visualizes verbose GC output
Expand All @@ -8,6 +8,10 @@ is free software released under GNU LGPL.
You can start GCViewer by simply double-clicking on gcviewer-1.3x.jar
or running java -jar gcviewer-1.3x.jar (it needs a java 1.6 vm to run).

For a cmdline based report summary just type:
java -jar gcviewer-1.3x.jar gc.log summary.csv
to gegenrate a report.


Supported verbose:gc formats are:

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<configuration>
<archive>
<manifest>
<mainClass>com.tagtraum.perf.gcviewer.GCViewer</mainClass>
<mainClass>com.tagtraum.perf.gcviewer.Main</mainClass>
<addClasspath>true</addClasspath>
</manifest>
</archive>
Expand Down
62 changes: 62 additions & 0 deletions src/main/java/com/tagtraum/perf/gcviewer/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.tagtraum.perf.gcviewer;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

import javax.swing.SwingUtilities;

import com.tagtraum.perf.gcviewer.exp.summary.SummaryExporter;
import com.tagtraum.perf.gcviewer.imp.DataReader;
import com.tagtraum.perf.gcviewer.imp.DataReaderFactory;
import com.tagtraum.perf.gcviewer.model.GCModel;

public class Main {

public static void main(final String[] args) {
if (args.length == 2) {
final String gcfile = args[0];
final String summaryFilePath = args[1];

//export summary:
try {
exportSummary(summaryFilePath, gcfile);
}
catch(IOException e1) {
e1.printStackTrace();
}
//exit: quick & dirty, but does not really matter
System.exit(0);

} else if (args.length > 1) {
usage();
} else {
GCViewer.main(args);
}
}

private static void exportSummary(String summaryFilePath, String gcFilename) throws IOException
{
SummaryExporter exporter = new SummaryExporter();
GCModel model = loadModel(new File(gcFilename).toURI().toURL());
exporter.exportSummaryFromModel(model, gcFilename, summaryFilePath);
}

private static GCModel loadModel(final URL url) throws IOException {
DataReaderFactory factory = new DataReaderFactory();
final InputStream in = url.openStream();
final DataReader reader = factory.getDataReader(in);
final GCModel model = reader.read();
model.setURL(url);
return model;

}

private static void usage() {
System.out.println("Welcome to GCViewer with cmdline");
System.out.println("java -jar gcviewer.jar [<gc-log-file>] [<export.csv>]");
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
*
*/
package com.tagtraum.perf.gcviewer.exp.summary;

/**
* @author sean
*
*/
public class CsvSummaryExportFormatter implements ISummaryExportFormatter {

private String separator = ", ";

/* (non-Javadoc)
* @see com.tagtraum.perf.gcviewer.exp.ISummaryExportFormatter#exportValue(java.lang.String, java.lang.String)
*/
//@Override
public String formatLine(String tag, String value, String units) {
return tag + separator + value + separator + units;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
*
*/
package com.tagtraum.perf.gcviewer.exp.summary;

/**
* @author sean
*
*/
public interface ISummaryExportFormatter {
String formatLine(String tag, String value, String units);
}
Loading