HeapDumpReader.java :  » IDE » tIDE » tide » profiler » Java Open Source

Java Open Source » IDE » tIDE 
tIDE » tide » profiler » HeapDumpReader.java
package tide.profiler;

import snow.sortabletable.*;
import snow.utils.storage.FileUtils;
import java.io.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

/** NOT DONE YET ! TODO...
*/
public final class HeapDumpReader
{
   private HeapDumpReader()
   {
   }

   private static void readHeapDump(File f) throws Exception
   {
      long t = System.currentTimeMillis();
      RandomAccessFile raf = new RandomAccessFile(f, "r");
      String line = null;
      int count = 0;
      while ((line = raf.readLine())!=null)  // EXTREMELY SLOW
      {
         count++;
      }
      FileUtils.closeIgnoringExceptions(raf);

      System.out.println(""+(System.currentTimeMillis()-t)+" ms, "+count+" lines");
   }

   private static void readHeapDump2(File f) throws Exception
   {
      long t = System.currentTimeMillis();
      LineNumberReader dis = new LineNumberReader(new FileReader(f));
      String line = null;
      int count = 0;
      dis.setLineNumber(10000000);
      while ((line = dis.readLine())!=null)
      {
         count++;

      }
      FileUtils.closeIgnoringExceptions(dis);

      System.out.println(""+(System.currentTimeMillis()-t)+" ms, "+count+" lines "+dis.getLineNumber());
   }


/*
   public static void main(String[] args)
   {
      try{
         readHeapDump2(new File("C:/proj/tide/profiler/snow.screenshot.ScreenShot.hprof_heap_dump.txt"));
         readHeapDump2(new File("C:/proj/tide/profiler/snow.screenshot.ScreenShot.hprof_heap_dump.txt"));
         readHeapDump2(new File("C:/proj/tide/profiler/snow.screenshot.ScreenShot.hprof_heap_dump.txt"));

      }
      catch(Exception e) {
        e.printStackTrace();
      }
   }*/

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.