Search in sources :

Example 1 with GcResourceFile

use of com.tagtraum.perf.gcviewer.model.GcResourceFile in project GCViewer by chewiebug.

the class DataReaderFacade method loadModel.

/**
     * Loads a model from a given <code>gcResource</code> logging all exceptions that occur.
     *
     * @param gcResource where to find data to be parsed
     * @return instance of GCModel containing all information that was parsed
     * @throws DataReaderException if any exception occurred, it is logged and added as the cause
     * to this exception
     */
public GCModel loadModel(GCResource gcResource) throws DataReaderException {
    if (gcResource == null) {
        throw new NullPointerException("gcResource must never be null");
    }
    if (gcResource instanceof GcResourceSeries) {
        return loadModelFromSeries((GcResourceSeries) gcResource);
    }
    if (!(gcResource instanceof GcResourceFile))
        throw new UnsupportedOperationException("Only supported for files!");
    DataReaderException dataReaderException = new DataReaderException();
    GCModel model = null;
    Logger logger = gcResource.getLogger();
    try {
        logger.info("GCViewer version " + BuildInfoReader.getVersion() + " (" + BuildInfoReader.getBuildDate() + ")");
        model = readModel((GcResourceFile) gcResource);
    } catch (RuntimeException | IOException e) {
        dataReaderException.initCause(e);
        logger.warning(LocalisationHelper.getString("fileopen_dialog_read_file_failed") + "\n" + e.toString() + " " + e.getLocalizedMessage());
    }
    if (dataReaderException.getCause() != null) {
        throw dataReaderException;
    }
    return model;
}
Also used : IOException(java.io.IOException) GcResourceFile(com.tagtraum.perf.gcviewer.model.GcResourceFile) Logger(java.util.logging.Logger) GcResourceSeries(com.tagtraum.perf.gcviewer.model.GcResourceSeries) GCModel(com.tagtraum.perf.gcviewer.model.GCModel)

Example 2 with GcResourceFile

use of com.tagtraum.perf.gcviewer.model.GcResourceFile in project GCViewer by chewiebug.

the class GCViewerTest method singleArgumentOpensGui.

@Test
public void singleArgumentOpensGui() throws Exception {
    GCViewerGuiController controller = mock(GCViewerGuiController.class);
    GCViewer gcViewer = new GCViewer(controller, new GCViewerArgsParser());
    String[] args = { "some_gc.log" };
    gcViewer.doMain(args);
    verify(controller).startGui(new GcResourceFile("some_gc.log"));
    assertThat(outContent.toString(), isEmptyString());
    assertThat(errContent.toString(), isEmptyString());
}
Also used : Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) Matchers.containsString(org.hamcrest.Matchers.containsString) GcResourceFile(com.tagtraum.perf.gcviewer.model.GcResourceFile) GCViewerGuiController(com.tagtraum.perf.gcviewer.ctrl.impl.GCViewerGuiController) Test(org.junit.Test)

Example 3 with GcResourceFile

use of com.tagtraum.perf.gcviewer.model.GcResourceFile in project GCViewer by chewiebug.

the class ImportPerformanceTest method main.

public static void main(String[] args) throws IOException, InterruptedException {
    IntData performanceData = new IntData();
    for (int i = 0; i < 10; i++) {
        long start = System.currentTimeMillis();
        DataReader dataReader = new DataReaderFactory().getDataReader(new GcResourceFile(args[0]), new FileInputStream(args[0]));
        dataReader.read();
        performanceData.add((int) (System.currentTimeMillis() - start));
    }
    printIntData(args[0], performanceData);
}
Also used : DataReader(com.tagtraum.perf.gcviewer.imp.DataReader) DataReaderFactory(com.tagtraum.perf.gcviewer.imp.DataReaderFactory) IntData(com.tagtraum.perf.gcviewer.math.IntData) GcResourceFile(com.tagtraum.perf.gcviewer.model.GcResourceFile) FileInputStream(java.io.FileInputStream)

Example 4 with GcResourceFile

use of com.tagtraum.perf.gcviewer.model.GcResourceFile in project GCViewer by chewiebug.

the class GCResourceGroup method getGcResourceSeries.

private GCResource getGcResourceSeries(String entry) {
    GCResource resource;
    List<GCResource> series = new ArrayList<>();
    for (String s : entry.split(SERIES_SEPARATOR)) {
        series.add(new GcResourceFile(s));
    }
    resource = new GcResourceSeries(series);
    return resource;
}
Also used : GCResource(com.tagtraum.perf.gcviewer.model.GCResource) ArrayList(java.util.ArrayList) GcResourceFile(com.tagtraum.perf.gcviewer.model.GcResourceFile) GcResourceSeries(com.tagtraum.perf.gcviewer.model.GcResourceSeries)

Example 5 with GcResourceFile

use of com.tagtraum.perf.gcviewer.model.GcResourceFile in project GCViewer by chewiebug.

the class TestDataReaderSun1_6_0 method testPrintCmsStatisticsRemark.

@Test
public void testPrintCmsStatisticsRemark() throws Exception {
    ByteArrayInputStream in = new ByteArrayInputStream(("2012-10-20T18:04:59.443+0200: 2.918: [GC[YG occupancy: 8752 K (78656 K)]2.918: [Rescan (parallel)  (Survivor:1chunks) Finished young gen rescan work in 2th thread: 0.000 sec" + "\nFinished young gen rescan work in 1th thread: 0.000 sec" + "\nFinished young gen rescan work in 0th thread: 0.000 sec" + "\nFinished remaining root rescan work in 1th thread: 0.000 sec" + "\nFinished remaining root rescan work in 2th thread: 0.000 sec" + "\nFinished remaining root rescan work in 0th thread: 0.000 sec" + "\nFinished dirty card rescan work in 0th thread: 0.001 sec" + "\nFinished dirty card rescan work in 2th thread: 0.001 sec" + "\nFinished dirty card rescan work in 1th thread: 0.001 sec" + "\nFinished young gen rescan work in 3th thread: 0.000 sec" + "\nFinished remaining root rescan work in 3th thread: 0.000 sec" + "\nFinished dirty card rescan work in 3th thread: 0.000 sec" + "\nFinished work stealing in 3th thread: 0.000 sec" + "\nFinished work stealing in 2th thread: 0.000 sec" + "\nFinished work stealing in 0th thread: 0.000 sec" + "\nFinished work stealing in 1th thread: 0.000 sec" + "\n, 0.0008918 secs]2.919: [weak refs processing, 0.0000057 secs]2.919: [class unloading, 0.0001020 secs]2.919: [scrub symbol & string tables, 0.0003265 secs] [1 CMS-remark: 376134K(436928K)] 384886K(515584K), 0.0014952 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]").getBytes());
    DataReader reader = new DataReaderSun1_6_0(new GcResourceFile("byteArray"), in, GcLogType.SUN1_6);
    GCModel model = reader.read();
    assertEquals("GC count", 1, model.size());
    assertEquals("GC pause", 0.0014952, model.getGCPause().getMin(), 0.000000001);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) GcResourceFile(com.tagtraum.perf.gcviewer.model.GcResourceFile) GCModel(com.tagtraum.perf.gcviewer.model.GCModel) Test(org.junit.Test)

Aggregations

GcResourceFile (com.tagtraum.perf.gcviewer.model.GcResourceFile)186 Test (org.junit.Test)178 GCModel (com.tagtraum.perf.gcviewer.model.GCModel)133 ByteArrayInputStream (java.io.ByteArrayInputStream)118 InputStream (java.io.InputStream)69 GCResource (com.tagtraum.perf.gcviewer.model.GCResource)55 GCEvent (com.tagtraum.perf.gcviewer.model.GCEvent)21 GcResourceSeries (com.tagtraum.perf.gcviewer.model.GcResourceSeries)11 File (java.io.File)8 ArrayList (java.util.ArrayList)6 GCViewerGuiController (com.tagtraum.perf.gcviewer.ctrl.impl.GCViewerGuiController)2 AbstractGCEvent (com.tagtraum.perf.gcviewer.model.AbstractGCEvent)2 LogRecord (java.util.logging.LogRecord)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Matchers.isEmptyString (org.hamcrest.Matchers.isEmptyString)2 GCModelLoader (com.tagtraum.perf.gcviewer.ctrl.GCModelLoader)1 DataReader (com.tagtraum.perf.gcviewer.imp.DataReader)1 DataReaderFactory (com.tagtraum.perf.gcviewer.imp.DataReaderFactory)1 DoubleData (com.tagtraum.perf.gcviewer.math.DoubleData)1 IntData (com.tagtraum.perf.gcviewer.math.IntData)1