Package xbird.util.datetime

Examples of xbird.util.datetime.StopWatch


    public void testInt2QMap() {
        StringBuilder buf = new StringBuilder(1024);
        System.gc();
        long free = SystemUtils.getHeapFreeMemory();
        buf.append(" free(init): " + free);
        StopWatch sw = new StopWatch("testInt2QMap");
        Int2QCache<Integer> lru = new Int2QCache<Integer>(LIMIT);
        for(int i = 0; i < LOOP; i++) {
            lru.put(i, i);
        }
        Random random = new Random();
        for(int i = 0; i < LOOP / 2; i++) {
            int r = random.nextInt(LOOP - 1);
            lru.put(r, r);
        }
        buf.insert(0, sw.toString());
        long used = free - SystemUtils.getHeapFreeMemory();
        buf.append(", used(before GC): " + used);
        System.gc();
        used = free - SystemUtils.getHeapFreeMemory();
        buf.append(", used(after GC): " + used);
View Full Code Here


    public void testLongLruMap() {
        StringBuilder buf = new StringBuilder(1024);
        System.gc();
        long free = SystemUtils.getHeapFreeMemory();
        buf.append(" free(init): " + free);
        StopWatch sw = new StopWatch("testLongLruMap");
        LongLRUMap<Integer> lru = new LongLRUMap<Integer>(LIMIT);
        for(int i = 0; i < LOOP; i++) {
            lru.put(i, i);
        }
        buf.insert(0, sw.toString());
        Random random = new Random();
        for(int i = 0; i < LOOP / 2; i++) {
            int r = random.nextInt(LOOP - 1);
            lru.put(r, r);
        }
View Full Code Here

    public void testLong2QMap() {
        StringBuilder buf = new StringBuilder(1024);
        System.gc();
        long free = SystemUtils.getHeapFreeMemory();
        buf.append(" free(init): " + free);
        StopWatch sw = new StopWatch("testLong2QMap");
        Long2QCache<Integer> lru = new Long2QCache<Integer>(LIMIT);
        for(int i = 0; i < LOOP; i++) {
            lru.put(i, i);
        }
        Random random = new Random();
        for(int i = 0; i < LOOP / 2; i++) {
            int r = random.nextInt(LOOP - 1);
            lru.put(r, r);
        }
        buf.insert(0, sw.toString());
        long used = free - SystemUtils.getHeapFreeMemory();
        buf.append(", used(before GC): " + used);
        System.gc();
        used = free - SystemUtils.getHeapFreeMemory();
        buf.append(", used(after GC): " + used);
View Full Code Here

        }
        Arrays.sort(keys);
        final int[] values = ArrayUtils.copy(keys);
        ArrayUtils.shuffle(values);

        final StopWatch watchdog1 = new StopWatch("Construction of " + repeat + " objects");
        btree.setBulkloading(true, 0.1f, 0.1f);
        final SortedMap<Integer, Set<Integer>> expected = new TreeMap<Integer, Set<Integer>>();
        for(int i = 0; i < repeat; i++) {
            int k = keys[i];
            int v = values[i];
            Set<Integer> vset = expected.get(k);
            if(vset == null) {
                vset = new HashSet<Integer>();
                expected.put(k, vset);
            }
            vset.add(v);
            btree.addValue(new Value(k), new Value(v));
        }
        System.err.println(watchdog1);

        final StopWatch watchdog2 = new StopWatch("Searching " + repeat + " objects");
        btree.setBulkloading(false, 0.1f, 0.1f);
        final SortedMap<Integer, Set<Integer>> actual = new TreeMap<Integer, Set<Integer>>();
        btree.search(new IndexConditionANY(), new CallbackHandler() {
            public boolean indexInfo(Value value, long pointer) {
                throw new UnsupportedOperationException();
View Full Code Here

    /*
     * Test method for 'xbird.util.IntHash.put(int, V)'
     */
    public void testPut() {
        StopWatch sw = new StopWatch();
        long[] keys = new long[100000];
        LongHash<Long> hash = new LongHash<Long>();
        Random random = new Random(System.currentTimeMillis());
        for(int i = 0; i < 100000; i++) {
            int key = random.nextInt();
View Full Code Here

    public void testPut10000000() {
        put(10000000);
    }

    public void put(int times) {
        StopWatch sw = new StopWatch("[Long2LongOpenHashTest] testPut" + times);
        List<Long> keys = new ArrayList<Long>(times);
        Long2LongOpenHash hash = new Long2LongOpenHash(times);
        Random random = new Random(System.currentTimeMillis());
        for(int i = 0; i < times; i++) {
            long key = random.nextLong();
View Full Code Here

TOP

Related Classes of xbird.util.datetime.StopWatch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.