01: /**
02: *
03: */package com.dappit.Dapper.parser.profiler;
04:
05: /**
06: * @author Ohad Serfaty
07: *
08: * this class is not working properly. please try another way...
09: *
10: */
11: @SuppressWarnings("unused")
12: public class SimpleMemoryProfiler extends SimpleProfiler {
13:
14: private long startFreeMem;
15:
16: private long startTotalMem;
17: private long startMaxMemory;
18:
19: /* (non-Javadoc)
20: * @see com.dappit.Dapper.parser.profiler.SimpleProfiler#report(java.lang.String)
21: */
22: @Override
23: public double report(String reportPrefix) {
24: System.gc();
25: long currentFreeMem = Runtime.getRuntime().freeMemory();
26: long currentTotalMem = Runtime.getRuntime().totalMemory();
27: long currentMaxMemory = Runtime.getRuntime().maxMemory();
28:
29: System.out.println("free :" + currentFreeMem);
30: // System.out.println("total : " + currentTotalMem);
31: // System.out.println("max : " + currentMaxMemory);
32: if (reportPrefix != null)
33: System.err.println(reportPrefix + ": "
34: + (currentFreeMem - startFreeMem));
35: return currentFreeMem - startFreeMem;
36: }
37:
38: /* (non-Javadoc)
39: * @see com.dappit.Dapper.parser.profiler.SimpleProfiler#start()
40: */
41: @Override
42: public void start() {
43: System.gc();
44: startFreeMem = Runtime.getRuntime().freeMemory();
45: startTotalMem = Runtime.getRuntime().totalMemory();
46: startMaxMemory = Runtime.getRuntime().maxMemory();
47:
48: System.out.println("free :" + startFreeMem);
49: // System.out.println("total : " + startTotalMem);
50: // System.out.println("max : " + startMaxMemory);
51: }
52:
53: }
|