Examples of StopWatch


Examples of winterwell.utils.time.StopWatch

      @Override
      public boolean awaitTermination(long timeout, TimeUnit unit)
          throws InterruptedException {
        timeout = unit.toMillis(timeout);
        StopWatch sw = new StopWatch();
        while (running.get() > 0) {
          if (sw.getTime() >= timeout)
            return false;
        }
        return true;
      }
View Full Code Here

Examples of xbird.util.StopWatch

    private static void runBenchmarkWithZipfDistribution(int capacity, int round, double skew, long[] data, ReplacementAlgorithm algo) {
        ConcurrentPluggableCache<Long, Long> cache = new ConcurrentPluggableCache<Long, Long>(capacity);
        cache.setReplacementPolicy(ReplacementPolicySelector.<Long, Long> provide(capacity, algo));

        StopWatch watchdog = new StopWatch("capacity: " + capacity + ", round: " + round);
        for(int i = 0; i < round; i++) {
            long key = data[i];
            ICacheEntry<Long, Long> entry = cache.allocateEntry(key);
            entry.setValue(key);
            entry.unpin();
        }
        long miss = cache.getCacheMiss();
        double ratio = ((double) miss) / round;
        System.err.println("[Zipf (" + skew + ") - " + algo + "] read: " + round + ", miss: "
                + miss + ", miss ratio: " + ratio);
        System.err.println(watchdog.toString());
    }
View Full Code Here

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

Examples of xbird.util.datetime.StopWatch

            }
        }
    }

    private void execute(Reader reader, int timeout) throws XQueryException {
        final StopWatch sw = new StopWatch("elapsed time");
        if(_perfmon) {
            try {
                new PerfmonService().start();
            } catch (ServiceException e) {
                System.err.println(PrintUtils.prettyPrintStackTrace(e));
            }
        }
        if(timeout > 0) {
            TimerTask cancel = new TimerTask() {
                public void run() {
                    System.err.println("Execution Timeout: " + sw.toString());
                    System.exit(1);
                }
            };
            Timer timer = new Timer();
            timer.schedule(cancel, timeout * 1000);
            try {
                execute(reader);
            } catch (XQueryException e) {
                timer.cancel();
                throw e;
            }
            timer.cancel();
        } else {
            execute(reader);
        }
        if(_timing) {
            if(_timing_in_msec) {
                System.out.println('\n' + sw.elapsed() + " msec");
            } else {
                System.out.println();
                System.out.println(sw);
            }
        }
View Full Code Here

Examples of xbird.util.datetime.StopWatch

            throws XQueryException {
        SAXWriter saxwr = prepareSAXWriter(writer);
        Serializer ser = new SAXSerializer(saxwr, writer);
        Sequence<? extends Item> result = proc.execute(module);
        if(_timing) {
            final StopWatch sw = new StopWatch("print time");
            ser.emit(result);
            if(_timing_in_msec) {
                System.out.println('\n' + sw.elapsed() + " msec");
            } else {
                System.out.println();
                System.out.println(sw);
            }
        } else {
View Full Code Here

Examples of xbird.util.datetime.StopWatch

                throw new IllegalStateException("create collection failed: " + colpath, e);
            }
            session.setContextCollection(col);
        }
        String[] cmdArgs = arguments.toArray(new String[arguments.size()]);
        StopWatch sw = new StopWatch();
        boolean success = false;
        try {
            success = executeCommand(cmdArgs);
        } catch (CommandException e) {
            LOG.error("command failed: " + Arrays.toString(cmdArgs), e);
View Full Code Here

Examples of xbird.util.datetime.StopWatch

        OperatingSystemMXBean mx = ManagementFactory.getOperatingSystemMXBean();
        final com.sun.management.OperatingSystemMXBean sunmx = (com.sun.management.OperatingSystemMXBean) mx;
        long startCpuTime = sunmx.getProcessCpuTime();

        final double percent = scanPercentage / 100d;
        StopWatch watchdog = new StopWatch("nthreads: " + threads + ", capacity: " + capacity
                + ", scanPercentage: " + percent + ", scanLength: " + scanLength + ", pageSize: "
                + pageSize);

        final Segments pager = makeTempSegments(pageSize);
        final Status[] stats = new Status[threads];

        final boolean isGCLOCK = (algo == ReplacementAlgorithm.GClock);

        _start = _stop = false;
        final Thread[] thrs = new Thread[threads];
        for(int i = 0; i < threads; i++) {
            final Status stat = new Status();
            final int thrdnum = i;
            stats[i] = stat;
            thrs[i] = new Thread() {
                public void run() {
                    while(!_start) {
                        // Spin till Time To Go
                        try {
                            Thread.sleep(1);
                        } catch (Exception e) {
                        }
                    }
                    try {
                        if(lock == null) {
                            throw new IllegalStateException();
                        } else {
                            if(isGCLOCK) {
                                runBenchmarkWithZipfDistributionLockForGCLOCK(thrdnum, stat, lock, pager, cache, capacity, round, percent, scanLength, dist);
                            } else {
                                switch(algo) {
                                    case BpFullTwoQueue:
                                    case BpLRU:
                                        //runBenchmarkWithZipfDistributionLazySync(thrdnum, stat, lock, pager, cache, capacity, round, percent, scanLength, dist);
                                        runBenchmarkWithZipfDistributionLazySync2(thrdnum, stat, lock, pager, cache, capacity, round, percent, scanLength, dist);
                                        break;
                                    default:
                                        runBenchmarkWithZipfDistributionLock(thrdnum, stat, lock, pager, cache, capacity, round, percent, scanLength, dist);
                                        break;
                                }
                            }
                        }
                    } catch (Throwable e) {
                        e.printStackTrace();
                    }
                }
            };
        }
        PerfmonService perfmon = new PerfmonService(3000);
        if(enableStat) {
            perfmon.start();
        }
        // Run threads
        for(int i = 0; i < threads; i++) {
            thrs[i].start();
        }
        _start = true;
        try {
            Thread.sleep(TIME_TO_EST);
        } catch (InterruptedException e) {
        }
        _stop = true;
        for(int i = 0; i < threads; i++) {
            thrs[i].join();
        }
        if(enableStat) {
            perfmon.stop();
        }
        long elapsedCpuTime = sunmx.getProcessCpuTime() - startCpuTime;

        long numOps = 0L, cacheMisses = 0L, elapsed = 0L;
        int ioContention = 0;
        for(int i = 0; i < threads; i++) {
            numOps += stats[i].ops;
            cacheMisses += stats[i].miss;
            elapsed += stats[i].mills;
            ioContention += stats[i].iocontention;
        }
        long avgElapsedInSec = (elapsed / threads) / 1000L;
        long opsPerSec = numOps / avgElapsedInSec;

        long hit = numOps - cacheMisses;
        double hitRatio = ((double) hit) / numOps;
        double missRatio = ((double) cacheMisses) / numOps;
        System.err.println("["
                + algo
                + ((algo == ReplacementAlgorithm.NbGClock || algo == ReplacementAlgorithm.NbGClockK) ? ", counter type: "
                        + System.getProperty("xbird.counter", "striped")
                        : "")
                + " - "
                + filename
                + "] synchronization: "
                + (useRWlock ? "rwlock" : (lock == null ? "sync"
                        : ((lock instanceof NoopLock) ? "non-blocking"
                                : lock.getClass().getSimpleName()))) + ", read: " + numOps
                + ", miss: " + cacheMisses + ", hit ratio: " + hitRatio + ", miss ratio: "
                + missRatio + ", io contention: " + ioContention);
        System.err.println(watchdog.toString());
        System.err.println("number of ops: " + numOps + ", average number of ops per second: "
                + opsPerSec);
        System.err.println("Elapsed cpu time: " + DateTimeFormatter.formatNanoTime(elapsedCpuTime));
        System.err.flush();
View Full Code Here

Examples of xbird.util.datetime.StopWatch

        }
        throw new CommandException("Illegal argument: " + Arrays.toString(args));
    }

    protected void run(String[] args) {
        final StopWatch sw = new StopWatch();
        boolean success = false;
        try {
            String[] cmds = parseOptions(args);
            success = executeCommand(cmds);
        } catch (Throwable e) {
View Full Code Here

Examples of xbird.util.datetime.StopWatch

                        int nth = counter.getAndIncrement();
                        String testfilename = tests[nth];
                        String test = FileUtils.basename(testfilename) + "#" + nth;
                        //String[] args = new String[] { "-q", testfilename, "-o", OUTPUT_DEST + test };
                        String[] args = new String[] { "-q", testfilename, "-o", "/dev/null" };
                        StopWatch sw = new StopWatch("elapsed time of " + test);
                        try {
                            new InteractiveShell().run(args);
                        } catch (XQueryException e) {
                            Assert.fail("failed " + test, e);
                        }
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;
        final XQueryProcessor processor = new XQueryProcessor();
        XQueryModule mod = processor.parse(new FileInputStream(queryFile), new File(queryFile).toURI());
        Sequence result = processor.execute(mod);
        StringWriter res_sw = new StringWriter();
        final 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));
        if(RUN_ONLY) {
            res_sw.close();
            res_sw = null;
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.