1 9 package test.ozoneDB.DxLib; 10 11 import org.ozoneDB.DxLib.*; 12 13 14 class SimpleTest { 15 16 17 public static void main(String [] args) throws Exception { 18 DxDeque deque = new DxArrayDeque(1024); 19 deque.peek(); 20 deque.pushBottom("daniela"); 21 deque.pushBottom("knuffi"); 22 23 System.out.println(deque.count()); 24 System.out.println(deque.popBottom()); 25 System.out.println(deque.popBottom()); 26 27 deque.push("daniela"); 28 deque.push("knuffi"); 29 System.out.println(deque.pop()); 30 deque.push("mumpi"); 31 32 System.out.println(deque.count()); 33 System.out.println(deque.pop()); 34 System.out.println(deque.pop()); 35 36 37 } 39 40 41 public void testMemory() { 42 Runtime rt = Runtime.getRuntime(); 43 44 try { 45 DxVector bag = new DxArrayBag(); 46 for (int i = 0; i < 100000; i++) { 47 bag.add(new byte[100000]); 48 System.out.println("total:" + rt.totalMemory() + " free:" + rt.freeMemory()); 49 } 50 } catch (OutOfMemoryError e) { 51 System.gc(); 52 } 53 54 System.out.println("total:" + rt.totalMemory() + " free:" + rt.freeMemory()); 55 } 56 57 58 public static void testDiskHash(String [] args) throws Exception { 59 long start = System.currentTimeMillis(); 60 61 int count = Integer.valueOf(args[0]).intValue(); 62 boolean re_use = Boolean.valueOf(args[1]).booleanValue(); 63 System.out.println(count + ", " + re_use); 64 65 DxDiskHashMap map = new DxDiskHashMap("map/map", 100, 12, 8); 66 67 76 for (; ;) { 77 start = System.currentTimeMillis(); 78 for (int i = 0; i < count; i++) { 79 map.addForKey(String.valueOf(i), new Integer (i)); 80 } 81 System.out.println("\naddForKey(): " + (System.currentTimeMillis() - start) + "msec"); 82 83 start = System.currentTimeMillis(); 84 for (int i = 0; i < count; i++) { 85 String s = (String ) map.elementForKey(new Integer (i)); 86 if (!s.equals(String.valueOf(i))) { 87 throw new Exception ("falscher inhalt"); 88 } 89 } 90 System.out.println("\nelementForKey(): " + (System.currentTimeMillis() - start) + "msec"); 91 92 start = System.currentTimeMillis(); 93 for (int i = 0; i < count; i++) { 94 String s = (String ) map.removeForKey(new Integer (i)); 95 if (!s.equals(String.valueOf(i))) { 96 throw new Exception ("falscher inhalt"); 97 } 98 } 99 System.out.println("\nremoveForKey(): " + (System.currentTimeMillis() - start) + "msec"); 100 101 map.printStatistics(); 102 } 103 104 } 107 108 } 109 | Popular Tags |