@Test
  public void testGenCon() throws Exception {
    InputStream in = getInputStream("SampleJRockit1_5_12_gencon.txt");
    DataReader reader = new DataReaderJRockit1_5_0(in);
    GCModel model = reader.read();

    assertEquals("count", 8, model.size());

    GCEvent event = (GCEvent) model.get(0);
    assertEquals("timestamp", 6.038, event.getTimestamp(), 0.000001);
    assertEquals("name", Type.JROCKIT_GC.getName(), event.getExtendedType().getName());
    assertEquals("before", 3089328, event.getPreUsed());
    assertEquals("after", 352551, event.getPostUsed());
    assertEquals("total", 3145728, event.getTotal());
    assertEquals("pause", 0.1186, event.getPause(), 0.0000001);
  }
  @Test
  public void testGcPrioThroughput() throws Exception {
    InputStream in = getInputStream("SampleJRockit1_5_12_gcpriothroughput.txt");
    DataReader reader = new DataReaderJRockit1_5_0(in);
    GCModel model = reader.read();

    assertEquals("count", 8, model.size());

    GCEvent event = (GCEvent) model.get(0);
    assertEquals("timestamp", 4.817, event.getTimestamp(), 0.000001);
    assertEquals("name", Type.JROCKIT_GC.getName(), event.getExtendedType().getName());
    assertEquals("before", 1641728, event.getPreUsed());
    assertEquals("after", 148365, event.getPostUsed());
    assertEquals("total", 3145728, event.getTotal());
    assertEquals("pause", 0.039959, event.getPause(), 0.0000001);
  }
  @Test
  public void testSimpleOpts() throws Exception {
    InputStream in = getInputStream("SampleJRockit1_5_12-gcreport-simpleopts-singlecon.txt");
    DataReader reader = new DataReaderJRockit1_5_0(in);
    GCModel model = reader.read();

    assertEquals("count", 5, model.size());

    GCEvent event = (GCEvent) model.get(0);
    assertEquals("timestamp", 6.771, event.getTimestamp(), 0.000001);
    assertEquals("name", Type.JROCKIT_GC.getName(), event.getExtendedType().getName());
    assertEquals("before", 3145728, event.getPreUsed());
    assertEquals("after", 296406, event.getPostUsed());
    assertEquals("total", 3145728, event.getTotal());
    assertEquals("pause", 0.066, event.getPause(), 0.0000001);
  }
  @Test
  public void testGcPrioPausetime() throws Exception {
    TestLogHandler handler = new TestLogHandler();
    handler.setLevel(Level.WARNING);
    IMP_LOGGER.addHandler(handler);
    DATA_READER_FACTORY_LOGGER.addHandler(handler);

    InputStream in = getInputStream("SampleJRockit1_5_12_gcpriopausetime.txt");
    DataReader reader = new DataReaderJRockit1_5_0(in);
    GCModel model = reader.read();

    assertEquals("count", 10, model.size());

    GCEvent event = (GCEvent) model.get(0);
    assertEquals("timestamp", 6.290, event.getTimestamp(), 0.000001);
    assertEquals("name", Type.JROCKIT_GC.getName(), event.getExtendedType().getName());
    assertEquals("before", 3128161, event.getPreUsed());
    assertEquals("after", 296406, event.getPostUsed());
    assertEquals("total", 3145728, event.getTotal());
    assertEquals("pause", 0.059084, event.getPause(), 0.0000001);

    assertEquals("number of warnings", 6, handler.getCount());
  }
Exemplo n.º 5
0
 public GCModel read() throws IOException {
   if (LOG.isLoggable(Level.INFO)) LOG.info("Reading IBM 1.3.1 format...");
   try {
     final GCModel model = new GCModel(true);
     model.setFormat(GCModel.Format.IBM_VERBOSE_GC);
     int state = 0;
     String line = null;
     GCEvent lastEvent = new GCEvent();
     GCEvent event = null;
     long basetime = 0;
     cycleStartGCFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy", Locale.US);
     while ((line = in.readLine()) != null) {
       final String trimmedLine = line.trim();
       if (!"".equals(trimmedLine)
           && !trimmedLine.startsWith("<GC: ")
           && !trimmedLine.startsWith("<")) {
         System.err.println("Malformed line (" + in.getLineNumber() + "): " + line);
         state = 0;
       }
       switch (state) {
         case 0:
           if (line.indexOf("Allocation Failure.") != -1) {
             event = new GCEvent();
             event.setType(AbstractGCEvent.Type.FULL_GC);
             event.setTimestamp(lastEvent.getTimestamp() + parseTimeSinceLastAF(line));
             // stay in state 0
             break;
           } else if (line.indexOf("GC cycle started") != -1) { // can apparently occur without AF
             event = new GCEvent();
             event.setType(AbstractGCEvent.Type.FULL_GC);
             final long time = parseGCCycleStart(line);
             if (basetime == 0) basetime = time;
             event.setTimestamp((time - basetime) / 1000.0d);
             state++;
             break;
           } else if (line.indexOf("managing allocation failure, action=3") != -1) {
             event = new GCEvent();
             event.setType(AbstractGCEvent.Type.FULL_GC);
             event.setTimestamp(lastEvent.getTimestamp() + lastEvent.getPause());
             event.setPreUsed(parsePreUsedAFAction3(line));
             event.setPostUsed(event.getPreUsed());
             state = 2;
             break;
           }
           break;
         case 1:
           if (line.indexOf("freed") != -1 && line.indexOf("unloaded") == -1) {
             event.setPreUsed(parsePreUsed(line));
             event.setPostUsed(parsePostUsed(line));
             event.setTotal(parseTotalAfterGC(line));
             event.setPause(parsePause(line));
             model.add(event);
             lastEvent = event;
             event = null;
             state = 0;
             break;
           }
           break;
         case 2:
           if (line.indexOf("expanded heap by ") != -1
               || line.indexOf("expanded heap fully by ") != -1) {
             event.setTotal(parseTotalAfterHeapExpansion(line));
             state++;
             break;
           }
           break;
         case 3:
           if (line.indexOf("completed in ") != -1) {
             event.setPause(parsePause(line) - lastEvent.getPause());
             model.add(event);
             lastEvent = event;
             event = null;
             state = 0;
           }
           break;
         default:
       }
     }
     // System.err.println(model);
     return model;
   } finally {
     if (in != null)
       try {
         in.close();
       } catch (IOException ioe) {
       }
     if (LOG.isLoggable(Level.INFO)) LOG.info("Done reading.");
   }
 }