Examples of StopWatch


Examples of xbird.util.datetime.StopWatch

        System.gc();
        int gcBefore = SystemUtils.countGC();
        long free = SystemUtils.getHeapFreeMemory();
        StringBuilder stdbuf = new StringBuilder(256);
        stdbuf.append(" - free(init): " + StringUtils.displayBytesSize(free));
        final StopWatch sw = new StopWatch("[Saxon] " + queryFile);
        queryFile = XMARK_HOME + '/' + queryFile;
        final Configuration config = new Configuration();
        config.setHostLanguage(Configuration.XQUERY);
        final StaticQueryContext staticContext = new StaticQueryContext(config);
        staticContext.setBaseURI(new File(queryFile).toURI().toString());
        XQueryExpression exp = staticContext.compileQuery(IOUtils.toString(new FileInputStream(queryFile)));
        final DynamicQueryContext dynamicContext = new DynamicQueryContext(config);
        StringWriter res_sw = new StringWriter();
        Properties props = new Properties();
        //props.setProperty(OutputKeys.METHOD, "text");
        props.setProperty(SaxonOutputKeys.WRAP, "no");
        props.setProperty(OutputKeys.INDENT, "no");
        props.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
        exp.run(dynamicContext, new StreamResult(res_sw), props);
        String swresult = sw.toString();
        long used = SystemUtils.getHeapUsedMemory();
        stdbuf.append(", used(before GC): " + StringUtils.displayBytesSize(used));
        if(RUN_ONLY) {
            res_sw.close();
            res_sw = null;
View Full Code Here

Examples of xbird.util.datetime.StopWatch

        System.gc();
        int gcBefore = SystemUtils.countGC();
        long free = SystemUtils.getHeapFreeMemory();
        StringBuilder stdbuf = new StringBuilder(256);
        stdbuf.append(" - free(init): " + StringUtils.displayBytesSize(free));
        final StopWatch sw = new StopWatch("[Xbird] " + queryFile);
        queryFile = XMARK_HOME + '/' + queryFile;

        XQEngine engine = new XQEngineClient("//" + bindHost + ":1099/xbird/srv-01");
        QueryRequest request1 = new QueryRequest(IOUtils.toString(new FileInputStream(queryFile)), ReturnType.REMOTE_SEQUENCE);
        request1.setBaseUri(new File(queryFile).toURI());
        Object result1 = engine.execute(request1);
        RemoteSequence remoteSequence = (RemoteSequence) result1;

        StringWriter res_sw = new StringWriter();
        Serializer ser = new SAXSerializer(new SAXWriter(res_sw), res_sw);
        ser.emit(remoteSequence);
        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

Examples of xbird.util.datetime.StopWatch

        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("[Saxon] " + queryFile);
        queryFile = XMARK_HOME + '/' + queryFile;
        Configuration config = new Configuration();
        config.setHostLanguage(Configuration.XQUERY);
        StaticQueryContext staticContext = new StaticQueryContext(config);
        staticContext.setBaseURI(new File(queryFile).toURI().toString());
        XQueryExpression exp = staticContext.compileQuery(IOUtils.toString(new FileInputStream(queryFile)));
        DynamicQueryContext dynamicContext = new DynamicQueryContext(config);
        StringWriter res_sw = new StringWriter();
        Properties props = new Properties();
        //props.setProperty(OutputKeys.METHOD, "text");
        props.setProperty(SaxonOutputKeys.WRAP, "no");
        props.setProperty(OutputKeys.INDENT, "no");
        props.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
        exp.run(dynamicContext, new StreamResult(res_sw), props);
        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

Examples of xbird.util.datetime.StopWatch

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

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

Examples of xbird.util.datetime.StopWatch

        this.locks = new SoftHashMap<String, ReadWriteLock>(32);
    }

    public final void handleRequest(@Nonnull final SocketChannel inChannel, @Nonnull final Socket socket)
            throws IOException {
        final StopWatch sw = new StopWatch();
        if(!inChannel.isBlocking()) {
            inChannel.configureBlocking(true);
        }

        InputStream in = socket.getInputStream();
        DataInputStream dis = new DataInputStream(in);

        String fname = IOUtils.readString(dis);
        String dirPath = IOUtils.readString(dis);
        long len = dis.readLong();
        boolean append = dis.readBoolean();
        boolean ackRequired = dis.readBoolean();
        boolean hasAdditionalHeader = dis.readBoolean();
        if(hasAdditionalHeader) {
            readAdditionalHeader(dis, fname, dirPath, len, append, ackRequired);
        }

        final File file;
        if(dirPath == null) {
            file = new File(baseDir, fname);
        } else {
            File dir = FileUtils.resolvePath(baseDir, dirPath);
            file = new File(dir, fname);
        }

        preFileAppend(file, append);
        final FileOutputStream dst = new FileOutputStream(file, append);
        final String fp = file.getAbsolutePath();
        final ReadWriteLock filelock = accquireLock(fp, locks);
        final FileChannel fileCh = dst.getChannel();
        final long startPos = file.length();
        try {
            NIOUtils.transferFullyFrom(inChannel, 0, len, fileCh); // REVIEWME really an atomic operation?
        } finally {
            IOUtils.closeQuietly(fileCh, dst);
            releaseLock(fp, filelock, locks);
            postFileAppend(file, startPos, len);
        }
        if(ackRequired) {
            OutputStream out = socket.getOutputStream();
            DataOutputStream dos = new DataOutputStream(out);
            dos.writeLong(len);
            postAck(file, startPos, len);
        }

        if(LOG.isDebugEnabled()) {
            SocketAddress remoteAddr = socket.getRemoteSocketAddress();
            LOG.debug("Received a " + (append ? "part of file '" : "file '")
                    + file.getAbsolutePath() + "' of " + len + " bytes from " + remoteAddr + " in "
                    + sw.toString());
        }
    }
View Full Code Here

Examples of xbird.util.datetime.StopWatch

        System.gc();

        String queryStr = IOUtils.toString(new FileInputStream(queryFilePath));
        queryStr = queryStr.replace("fn:doc(\"auction.xml\")", "fn:doc('" + TARGET_FILE + "')");

        final StopWatch sw = new StopWatch("[Xbird_file] " + queryFilePath);
        final XQueryProcessor processor = new XQueryProcessor();
        // parse
        XQueryModule mod = processor.parse(queryStr, new File(queryFilePath).toURI());
        // execute              
        FastMultiByteArrayOutputStream out = new FastMultiByteArrayOutputStream();
View Full Code Here

Examples of xbird.util.datetime.StopWatch

        String queryStr = IOUtils.toString(new FileInputStream(queryFilePath));
        queryStr = queryStr.replace("fn:doc(\"auction.xml\")", "fn:collection('"
                + TARGET_COLLECTION + "')");

        final StopWatch sw = new StopWatch("[Xbird_collection] " + queryFilePath);
        final XQueryProcessor processor = new XQueryProcessor();
        // parse
        XQueryModule mod = processor.parse(queryStr, new File(queryFilePath).toURI());
        // execute
        FastMultiByteArrayOutputStream out = new FastMultiByteArrayOutputStream();
View Full Code Here

Examples of xbird.util.datetime.StopWatch

        if(sync) {
            InputStream in = socket.getInputStream();
            din = new DataInputStream(in);
        }
        final DataOutputStream dos = new DataOutputStream(out);
        final StopWatch sw = new StopWatch();
        FileInputStream src = null;
        final long nbytes;
        try {
            src = new FileInputStream(file);
            FileChannel fc = src.getChannel();

            String fileName = file.getName();
            IOUtils.writeString(fileName, dos);
            IOUtils.writeString(writeDirPath, dos);
            long xferBytes = (count == -1L) ? fc.size() : count;
            dos.writeLong(xferBytes);
            dos.writeBoolean(append); // append=false
            dos.writeBoolean(sync);
            if(handler == null) {
                dos.writeBoolean(false);
            } else {
                dos.writeBoolean(true);
                handler.writeAdditionalHeader(dos);
            }

            // send file using zero-copy send
            nbytes = fc.transferTo(fromPos, xferBytes, channel);
            if(LOG.isDebugEnabled()) {
                LOG.debug("Sent a file '" + file.getAbsolutePath() + "' of " + nbytes
                        + " bytes to " + dstSockAddr.toString() + " in " + sw.toString());
            }

            if(sync) {// receive ack in sync mode
                long remoteRecieved = din.readLong();
                if(remoteRecieved != xferBytes) {
View Full Code Here

Examples of xbird.util.datetime.StopWatch

        if(sync) {
            InputStream in = socket.getInputStream();
            din = new DataInputStream(in);
        }
        final DataOutputStream dos = new DataOutputStream(out);
        final StopWatch sw = new StopWatch();
        try {
            IOUtils.writeString(fileName, dos);
            IOUtils.writeString(writeDirPath, dos);
            long nbytes = data.size();
            dos.writeLong(nbytes);
            dos.writeBoolean(append);
            dos.writeBoolean(sync);
            if(handler == null) {
                dos.writeBoolean(false);
            } else {
                dos.writeBoolean(true);
                handler.writeAdditionalHeader(dos);
            }

            // send file using zero-copy send
            data.writeTo(out);

            if(LOG.isDebugEnabled()) {
                LOG.debug("Sent a file data '" + fileName + "' of " + nbytes + " bytes to "
                        + dstSockAddr.toString() + " in " + sw.toString());
            }

            if(sync) {// receive ack in sync mode
                long remoteRecieved = din.readLong();
                if(remoteRecieved != nbytes) {
View Full Code Here

Examples of xbird.util.datetime.StopWatch

    public void loadDocument(InputStream is) throws XQueryException {
        if(!(is instanceof FastBufferedInputStream)) {
            is = new FastBufferedInputStream(is);
        }
        _handler.init();
        final StopWatch sw = new StopWatch();
        try {
            _reader.parse(new InputSource(is));
        } catch (IOException ie) {
            throw new DynamicError("Invalid source", ie);
        } catch (SAXException se) {
            throw new DynamicError("Parse failed", se);
        }
        if(LOG.isDebugEnabled()) {
            LOG.debug("Elasped time of building a DTM: " + sw.elapsed() + " msec");
        }
        this._docid = nextDocumentId();
        if(_store instanceof IProfiledDocumentTable) {
            ((IProfiledDocumentTable) _store).setProfiling(true);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.