001: // You can redistribute this software and/or modify it under the terms of
002: // the Ozone Library License version 1 published by ozone-db.org.
003: //
004: // The original code and portions created by SMB are
005: // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
006: //
007: // $Id: SimpleTest.java,v 1.1 2001/12/18 10:31:30 per_nyfelt Exp $
008:
009: package org.ozoneDB.DxLib.test;
010:
011: import java.util.*;
012: import java.io.*;
013: import org.ozoneDB.DxLib.*;
014: import org.ozoneDB.core.*;
015:
016: class SimpleTest {
017:
018: public static void main(String[] args) throws Exception {
019: DxDeque deque = new DxArrayDeque(1024);
020: deque.peek();
021: deque.pushBottom("daniela");
022: deque.pushBottom("knuffi");
023:
024: System.out.println(deque.count());
025: System.out.println(deque.popBottom());
026: System.out.println(deque.popBottom());
027:
028: deque.push("daniela");
029: deque.push("knuffi");
030: System.out.println(deque.pop());
031: deque.push("mumpi");
032:
033: System.out.println(deque.count());
034: System.out.println(deque.pop());
035: System.out.println(deque.pop());
036:
037: // System.out.println ("\nzeit: " + (System.currentTimeMillis() - start) + "msec");
038: }
039:
040: public void testMemory() {
041: Runtime rt = Runtime.getRuntime();
042:
043: try {
044: DxVector bag = new DxArrayBag();
045: for (int i = 0; i < 100000; i++) {
046: bag.add(new byte[100000]);
047: System.out.println("total:" + rt.totalMemory()
048: + " free:" + rt.freeMemory());
049: }
050: } catch (OutOfMemoryError e) {
051: System.gc();
052: }
053:
054: System.out.println("total:" + rt.totalMemory() + " free:"
055: + rt.freeMemory());
056: }
057:
058: public static void testDiskHash(String[] args) throws Exception {
059: long start = System.currentTimeMillis();
060:
061: int count = Integer.valueOf(args[0]).intValue();
062: boolean re_use = Boolean.valueOf(args[1]).booleanValue();
063: System.out.println(count + ", " + re_use);
064:
065: DxDiskHashMap map = new DxDiskHashMap("map/map", 100, 12, 8);
066:
067: // if (re_use)
068: // map.re_use();
069: // else {
070: // for (int i=0; i<count; i++) {
071: // map.addForKey ("daniela", new Integer(i));
072: // }
073: // System.out.println ("\naddForKey(): " + (System.currentTimeMillis() - start) + "msec");
074: // }
075:
076: for (;;) {
077: start = System.currentTimeMillis();
078: for (int i = 0; i < count; i++) {
079: map.addForKey(String.valueOf(i), new Integer(i));
080: }
081: System.out.println("\naddForKey(): "
082: + (System.currentTimeMillis() - start) + "msec");
083:
084: start = System.currentTimeMillis();
085: for (int i = 0; i < count; i++) {
086: String s = (String) map.elementForKey(new Integer(i));
087: if (!s.equals(String.valueOf(i))) {
088: throw new Exception("falscher inhalt");
089: }
090: }
091: System.out.println("\nelementForKey(): "
092: + (System.currentTimeMillis() - start) + "msec");
093:
094: start = System.currentTimeMillis();
095: for (int i = 0; i < count; i++) {
096: String s = (String) map.removeForKey(new Integer(i));
097: if (!s.equals(String.valueOf(i))) {
098: throw new Exception("falscher inhalt");
099: }
100: }
101: System.out.println("\nremoveForKey(): "
102: + (System.currentTimeMillis() - start) + "msec");
103:
104: map.printStatistics();
105: }
106:
107: // map.close();
108: // System.out.println ("\nclose(): " + (System.currentTimeMillis() - start) + "msec");
109: }
110:
111: }
|