1 14 package org.compiere; 15 16 import java.util.*; 17 import java.math.*; 18 19 import org.compiere.util.*; 20 import org.compiere.model.*; 21 22 28 class Base 29 { 30 33 public static void test() 34 { 35 System.out.println("** Before Init **"); getMemoryUsed(); 37 Properties ctx = Env.initTest(1, false); 38 System.gc(); System.out.println("** Before Creation **"); 43 long start = getMemoryUsed(); 44 45 47 int AD_Window_ID = 102; 49 long startTime = System.currentTimeMillis(); 50 MWindowVO vo = MWindowVO.create(Env.getCtx(), 1, AD_Window_ID); 51 MWindow w = new MWindow(vo); 52 long endDef = System.currentTimeMillis(); 53 System.out.println("Load Definition Time in ms = " + String.valueOf(endDef-startTime)); 54 if (1==2) { 56 w.loadCompete(); 57 long endDefComplete = System.currentTimeMillis(); 58 System.out.println("Load Definition Complete Time in ms = " + String.valueOf(endDefComplete-startTime)); 59 } 60 w.query(); 61 long endData = System.currentTimeMillis(); 62 System.out.println("Load Data Time in ms = " + String.valueOf(endData-startTime)); 63 w.loadCompete(); 64 long endDataComplete = System.currentTimeMillis(); 65 System.out.println("Load Data Complete Time in ms = " + String.valueOf(endDataComplete-startTime)); 66 w.getTab(0).navigate(0); 67 68 71 System.out.println("** Before Dispose **"); 72 getMemoryUsed(); 73 w.dispose(); 74 System.out.println("** Before GC **"); 77 getMemoryUsed(); 78 w = null; 79 System.gc(); 80 System.out.println("** After GC **"); 81 getMemoryUsed(); 82 System.gc(); 83 84 System.out.println("** Final **"); 85 long complete = System.currentTimeMillis(); 86 System.out.println("Complete Time in ms = " + String.valueOf(complete-startTime)); 87 long end = getMemoryUsed(); 88 System.out.println("Memory increase in kB = End-Start=" + String.valueOf((end-start)/1024)); 89 listThreads(); 90 System.out.println("API Test"); 92 System.out.println("64.72=" + DB.getConvertedAmt(new BigDecimal(100.0), 116, 100,0,0)); 93 System.out.println("0.647169=" + DB.getConvesionRate(116, 100, null, null,0,0)); 94 System.out.println("12.5=" + UOMConversion.getConvertedQty(new BigDecimal(100.0), 101, 102, true)); 95 96 } 98 101 private static long getMemoryUsed() 102 { 103 long free = Runtime.getRuntime().freeMemory(); 104 long total = Runtime.getRuntime().totalMemory(); 105 long used = total - free; 106 System.out.println("Memory used in kB = Total(" 108 + String.valueOf(total/1024) + ")-Free(" 109 + String.valueOf(free/1024) + ") = " + String.valueOf(used/1024)); 110 System.out.println("Active Threads=" + Thread.activeCount()); 111 return used; 112 } 114 117 private static void sleep() 118 { 119 System.out.println(".. sleeping-ini .. -> " + Thread.activeCount()); 120 Thread.yield(); 121 try 122 { 123 Thread.sleep(1000); 124 } 125 catch (InterruptedException ie) 126 {} 127 System.out.println(".. sleeping-end .. -> " + Thread.activeCount()); 128 } 130 133 private static void listThreads() 134 { 135 Thread [] list = new Thread [Thread.activeCount()]; 136 for (int i = 0; i < list.length; i++) 138 { 139 if (list[i] != null) 140 System.out.println("Thread " + i + " - " + list[i].toString()); 141 } 142 } 144 147 public static void main(String [] args) 148 { 149 Base.test(); 150 Env.exitEnv(0); 151 } } | Popular Tags |