Package xbird.util.datetime

Examples of xbird.util.datetime.StopWatch


    }

    @Test
    @Ignore
    public void xtestPutDocument() throws XQueryException, DbException, FileNotFoundException {
        StopWatch sw = new StopWatch("testPutDocument");
        DbCollection xmark = DbCollection.getRootCollection().createCollection(COL_NAME);
        assert (xmark.getDirectory().exists());
        final DocumentTableModel dtm = new DocumentTableModel(false);
        File file = new File(TEST_FILE);
        dtm.loadDocument(new FileInputStream(file));
View Full Code Here


    }

    @Test
    public void testPutDocumentPageOutBig() throws XQueryException, DbException,
            FileNotFoundException {
        StopWatch sw = new StopWatch("testPutDocumentPageOutBig");
        DbCollection xmark = DbCollection.getRootCollection().createCollection(COL_NAME);
        assert (xmark.getDirectory().exists());
        File file = new File(TEST_FILE);
        IDocumentTable doc = new BigDocumentTable.PersistentBigDocumentTable(xmark, FileUtils.getFileName(file));
        final DocumentTableModel dtm = new DocumentTableModel(doc);
View Full Code Here

    public void testNormalSequence() throws FileNotFoundException, XQueryException {
        System.out.println(" ============ Materialized ============ ");
        final Sequence<? extends Item> result = doQuery(queryFile);
        final ValueSequence materialized = new ValueSequence(result.materialize(), null);

        StopWatch sw01 = new StopWatch("Sequence encoding time");
        byte[] encoded0 = ObjectUtils.toBytes(materialized);
        System.err.println(sw01);

        System.err.println("encoded size: " + encoded0.length + " bytes");

        StopWatch sw02 = new StopWatch("Sequence decoding time");
        ObjectUtils.readObjectQuietly(encoded0);
        System.err.println(sw02);
    }
View Full Code Here

        final Sequence<? extends Item> result = doQuery(queryFile);

        MarshalledSequence serResult = new MarshalledSequence(result, DynamicContext.DUMMY);       
        serResult.setPiped(piped);

        StopWatch sw1 = new StopWatch("SerializedSequence encoding time");
        byte[] encoded = ObjectUtils.toBytes(serResult);
        System.err.println(sw1);

        System.err.println("encoded size: " + encoded.length + " bytes");

        StopWatch sw2 = new StopWatch("SerializedSequence decoding time");
        Sequence<Item> decodedSeq1 = ObjectUtils.readObjectQuietly(encoded);
        System.err.println(sw2);

        StopWatch sw3 = new StopWatch("IncrementalDecodedSequnece encoding time");
        byte[] encoded2 = ObjectUtils.toBytes(decodedSeq1);
        System.err.println(sw3);

        StopWatch sw4 = new StopWatch("IncrementalDecodedSequnece decoding time");
        Sequence<Item> decodedSeq2 = ObjectUtils.readObjectQuietly(encoded2);
        System.err.println(sw4);

        MarshalledSequence reaccessed2 = (MarshalledSequence) decodedSeq2;
        reaccessed2.setReaccessable(true);
       
        // partial decode
        Iterator<Item> itor2 = decodedSeq2.iterator();
        for(int i = 0; i < 75; i++) {
            itor2.next();
        }

        StopWatch sw5 = new StopWatch("IncrementalDecodedSequnece (partially decoded: 100 items)  encoding time");
        byte[] encoded3 = ObjectUtils.toBytes(decodedSeq2);
        System.err.println(sw5);

        StopWatch sw6 = new StopWatch("IncrementalDecodedSequnece (partially decoded: 100 items) decoding time");
        Sequence<Item> decodedSeq3 = ObjectUtils.readObjectQuietly(encoded3);
        MarshalledSequence reaccessed3 = (MarshalledSequence) decodedSeq3;
        reaccessed3.setReaccessable(true);
        System.err.println(sw6);

        // full decode
        int count1 = 0;
        for(Item it : decodedSeq3) {
            count1++;
        }

        StopWatch sw7 = new StopWatch("!IncrementalDecodedSequnece (full decoded)  encoding time");
        byte[] encoded4 = ObjectUtils.toBytes(decodedSeq3);
        System.err.println(sw7);

        StopWatch sw8 = new StopWatch("!IncrementalDecodedSequnece (full decoded) decoding time");
        Sequence<Item> decodedSeq4 = ObjectUtils.readObjectQuietly(encoded4);
        System.err.println(sw8);

        int count2 = 0;
        for(Item it : decodedSeq4) {
View Full Code Here

        System.gc();
        int gcBefore = SystemUtils.countGC();
        long free = SystemUtils.getHeapFreeMemory();
        StringBuilder stdbuf = new StringBuilder(256);
        stdbuf.append(" - free(init): " + StringUtils.displayBytesSize(free));
        StopWatch sw = new StopWatch("[Xbird] " + queryFile);
        XQueryProcessor processor = new XQueryProcessor();
        XQueryModule mod = processor.parse(new FileInputStream(queryFile), new File(DOC_BASE).toURI());
        processor.compile(mod);
        System.err.println(mod.getExpression().toString());
        Sequence result = processor.execute(mod);
        StringWriter res_sw = new StringWriter();
        Serializer ser = new SAXSerializer(new SAXWriter(res_sw), res_sw);
        ser.emit(result);
        String swresult = sw.toString();
        long used = SystemUtils.getHeapUsedMemory();
        stdbuf.append(", used(before GC): " + StringUtils.displayBytesSize(used));
        System.gc();
        used = SystemUtils.getHeapUsedMemory();
        stdbuf.append(", used(after GC): " + StringUtils.displayBytesSize(used));
View Full Code Here

        BTree btree = new BTree(tmpFile, false);
        btree.create(false);

        List<byte[]> list = new ArrayList<byte[]>(REPEAT);
        Random random = new Random(54552542345L);
        StopWatch sw1 = new StopWatch("[BplusTreeUniq] Index Construction of " + REPEAT);
        for(int i = 0; i < REPEAT; i++) {
            long v = random.nextLong();
            byte[] b = Primitives.toBytes(v);
            Value k = new Value(b);
            Assert.assertTrue(btree.addValue(k, v) == -1);
            list.add(b);
        }
        System.err.println(sw1);

        btree.flush(true, true);

        StopWatch sw2 = new StopWatch("[BplusTreeUniq] Index Search of " + (REPEAT / 2));
        for(int i = REPEAT - 1; i >= 0; i -= 2) {
            byte[] b = list.get(i);
            Assert.assertEquals("#" + i, Primitives.getLong(b), btree.findValue(new Key(b)));
        }
        System.err.println(sw2);
View Full Code Here

        SortedStaticHash hash = new SortedStaticHash(tmpFile, buckets);
        hash.create(false);

        List<byte[]> list = new ArrayList<byte[]>(REPEAT);
        Random random = new Random(54552542345L);
        StopWatch sw1 = new StopWatch("[SortedStaticHash_with_" + buckets
                + "_buckets] Index Construction of " + REPEAT);
        for(int i = 0; i < REPEAT; i++) {
            String d = Double.toString(random.nextLong());
            byte[] b = StringUtils.getBytes(d);
            Key k = new Key(b);
            Value v = new Value(b);
            Assert.assertNull(hash.addValue(k, v));
            list.add(b);
        }
        System.err.println(sw1);

        hash.flush(true, true);

        StopWatch sw2 = new StopWatch("[SortedStaticHash_with_" + buckets
                + "_buckets] Index Search of " + (REPEAT / 2));
        for(int i = REPEAT - 1; i >= 0; i -= 2) {
            byte[] b = list.get(i);
            Assert.assertEquals("#" + i, new Value(b), hash.findValue(new Key(b)));
        }
View Full Code Here

        SortedStaticHash hash = new SortedStaticHash(tmpFile, 1024 * 2, buckets);
        hash.create(false);

        List<byte[]> list = new ArrayList<byte[]>(REPEAT);
        Random random = new Random(54552542345L);
        StopWatch sw1 = new StopWatch("[SortedStaticHash_with_" + buckets
                + "_buckets_2kPage] Index Construction of " + REPEAT);
        for(int i = 0; i < REPEAT; i++) {
            String d = Double.toString(random.nextLong());
            byte[] b = StringUtils.getBytes(d);
            Key k = new Key(b);
            Value v = new Value(b);
            Assert.assertNull(hash.addValue(k, v));
            list.add(b);
        }
        System.err.println(sw1);

        hash.flush(true, true);

        StopWatch sw2 = new StopWatch("[SortedStaticHash_with_" + buckets
                + "_buckets_2kPage] Index Search of " + (REPEAT / 2));
        for(int i = REPEAT - 1; i >= 0; i -= 2) {
            byte[] b = list.get(i);
            Assert.assertEquals("#" + i, new Value(b), hash.findValue(new Key(b)));
        }
View Full Code Here

        SortedStaticHash hash = new SortedStaticHash(tmpFile, buckets);
        hash.create(false);

        List<byte[]> list = new ArrayList<byte[]>(REPEAT);
        Random random = new Random(54552542345L);
        StopWatch sw1 = new StopWatch("[SortedStaticHash_with_" + buckets
                + "_buckets] Index Construction of " + REPEAT);
        for(int i = 0; i < REPEAT; i++) {
            String d = Double.toString(random.nextLong());
            byte[] b = StringUtils.getBytes(d);
            Key k = new Key(b);
            Value v = new Value(b);
            Assert.assertNull(hash.addValue(k, v));
            list.add(b);
        }
        System.err.println(sw1);

        hash.flush(true, true);

        StopWatch sw2 = new StopWatch("[SortedStaticHash_with_" + buckets
                + "_buckets] Index Search of " + (REPEAT / 2));
        for(int i = REPEAT - 1; i >= 0; i -= 2) {
            byte[] b = list.get(i);
            Assert.assertEquals("#" + i, new Value(b), hash.findValue(new Key(b)));
        }
View Full Code Here

        BIndexFile bfile = new BIndexFile(tmpFile, false);
        bfile.create(false);

        List<byte[]> list = new ArrayList<byte[]>(REPEAT);
        Random random = new Random(54552542345L);
        StopWatch sw1 = new StopWatch("[BFileUniq] Index Construction of " + REPEAT);
        for(int i = 0; i < REPEAT; i++) {
            long v = random.nextLong();
            byte[] b = Primitives.toBytes(v);
            Value k = new Value(b);
            bfile.addValue(k, b);
            list.add(b);
        }
        System.err.println(sw1);

        bfile.flush(true, true);

        StopWatch sw2 = new StopWatch("[BFileUniq] Index Search of " + (REPEAT / 2));
        for(int i = REPEAT - 1; i >= 0; i -= 2) {
            byte[] b = list.get(i);
            Assert.assertEquals("#" + i, new Value(b), bfile.getValue(new Value(b)));
        }
        System.err.println(sw2);
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.