long extraSleepTime = sw.elapsed(TimeUnit.MILLISECONDS) - SLEEP_INTERVAL_MS; Map<String, GcTimes> gcTimesAfterSleep = getGcTimes();
/** * Ensure passed zookeeper is connected. * @param timeout Time to wait on established Connection */ public static ZooKeeper ensureConnectedZooKeeper(ZooKeeper zookeeper, int timeout) throws ZooKeeperConnectionException { if (zookeeper.getState().isConnected()) { return zookeeper; } Stopwatch stopWatch = Stopwatch.createStarted(); // Make sure we are connected before we hand it back. while(!zookeeper.getState().isConnected()) { Threads.sleep(1); if (stopWatch.elapsed(TimeUnit.MILLISECONDS) > timeout) { throw new ZooKeeperConnectionException("Failed connect after waiting " + stopWatch.elapsed(TimeUnit.MILLISECONDS) + "ms (zk session timeout); " + zookeeper); } } return zookeeper; } }
@Override protected int doWork() throws Exception { generateRegionsAndServers(); String methodName = "roundRobinAssignment"; LOG.info("Calling " + methodName); Stopwatch watch = Stopwatch.createStarted(); loadBalancer.roundRobinAssignment(regions, servers); System.out.print(formatResults(methodName, watch.elapsed(TimeUnit.MILLISECONDS))); methodName = "retainAssignment"; LOG.info("Calling " + methodName); watch.reset().start(); loadBalancer.retainAssignment(regionServerMap, servers); System.out.print(formatResults(methodName, watch.elapsed(TimeUnit.MILLISECONDS))); methodName = "balanceCluster"; LOG.info("Calling " + methodName); watch.reset().start(); loadBalancer.balanceCluster(serverRegionMap); System.out.print(formatResults(methodName, watch.elapsed(TimeUnit.MILLISECONDS))); return EXIT_SUCCESS; }
protected void testHdfsStreaming(Path filename) throws IOException { byte[] buf = new byte[1024]; FileSystem fs = filename.getFileSystem(getConf()); // read the file from start to finish Stopwatch fileOpenTimer = Stopwatch.createUnstarted(); Stopwatch streamTimer = Stopwatch.createUnstarted(); fileOpenTimer.start(); FSDataInputStream in = fs.open(filename); fileOpenTimer.stop(); long totalBytes = 0; streamTimer.start(); while (true) { int read = in.read(buf); if (read < 0) { break; } totalBytes += read; } streamTimer.stop(); double throughput = (double)totalBytes / streamTimer.elapsed(TimeUnit.SECONDS); System.out.println("HDFS streaming: "); System.out.println("total time to open: " + fileOpenTimer.elapsed(TimeUnit.MILLISECONDS) + " ms"); System.out.println("total time to read: " + streamTimer.elapsed(TimeUnit.MILLISECONDS) + " ms"); System.out.println("total bytes: " + totalBytes + " bytes (" + StringUtils.humanReadableInt(totalBytes) + ")"); System.out.println("throghput : " + StringUtils.humanReadableInt((long)throughput) + "B/s"); }
double throughput = (double)totalBytes / scanTimer.elapsed(TimeUnit.SECONDS); double throughputRows = (double)numRows / scanTimer.elapsed(TimeUnit.SECONDS); double throughputCells = (double)numCells / scanTimer.elapsed(TimeUnit.SECONDS); scanOpenTimer.elapsed(TimeUnit.MILLISECONDS) + " ms"); System.out.println("total time to scan: " + scanTimer.elapsed(TimeUnit.MILLISECONDS) + " ms");
double throughput = (double)totalBytes / scanTimer.elapsed(TimeUnit.SECONDS); double throughputRows = (double)numRows / scanTimer.elapsed(TimeUnit.SECONDS); double throughputCells = (double)numCells / scanTimer.elapsed(TimeUnit.SECONDS); scanOpenTimer.elapsed(TimeUnit.MILLISECONDS) + " ms"); System.out.println("total time to scan: " + scanTimer.elapsed(TimeUnit.MILLISECONDS) + " ms");
double throughput = (double)totalBytes / scanTimer.elapsed(TimeUnit.SECONDS); double throughputRows = (double)numRows / scanTimer.elapsed(TimeUnit.SECONDS); double throughputCells = (double)numCells / scanTimer.elapsed(TimeUnit.SECONDS); snapshotRestoreTimer.elapsed(TimeUnit.MILLISECONDS) + " ms"); System.out.println("total time to open scanner: " + scanOpenTimer.elapsed(TimeUnit.MILLISECONDS) + " ms"); System.out.println("total time to scan: " + scanTimer.elapsed(TimeUnit.MILLISECONDS) + " ms");
table.get(g); if (i % printInterval == 0) { LOG.info("Get " + printInterval + "/" + stopWatch.elapsed(java.util.concurrent.TimeUnit.MILLISECONDS)); stopWatch.reset(); stopWatch.start(); mutator.mutate(p); if (i % printInterval == 0) { LOG.info("Put " + printInterval + "/" + stopWatch.elapsed(java.util.concurrent.TimeUnit.MILLISECONDS)); stopWatch.reset(); stopWatch.start();
double throughput = (double)totalBytes / scanTimer.elapsed(TimeUnit.SECONDS); double throughputRows = (double)numRows / scanTimer.elapsed(TimeUnit.SECONDS); double throughputCells = (double)numCells / scanTimer.elapsed(TimeUnit.SECONDS); tableOpenTimer.elapsed(TimeUnit.MILLISECONDS) + " ms"); System.out.println("total time to open scanner: " + scanOpenTimer.elapsed(TimeUnit.MILLISECONDS) + " ms"); System.out.println("total time to scan: " + scanTimer.elapsed(TimeUnit.MILLISECONDS) + " ms");
/** * Ensure passed zookeeper is connected. * @param timeout Time to wait on established Connection */ public static ZooKeeper ensureConnectedZooKeeper(ZooKeeper zookeeper, int timeout) throws ZooKeeperConnectionException { if (zookeeper.getState().isConnected()) { return zookeeper; } Stopwatch stopWatch = Stopwatch.createStarted(); // Make sure we are connected before we hand it back. while(!zookeeper.getState().isConnected()) { Threads.sleep(1); if (stopWatch.elapsed(TimeUnit.MILLISECONDS) > timeout) { throw new ZooKeeperConnectionException("Failed connect after waiting " + stopWatch.elapsed(TimeUnit.MILLISECONDS) + "ms (zk session timeout); " + zookeeper); } } return zookeeper; } }
table.get(g); if (i % printInterval == 0) { LOG.info("Get " + printInterval + "/" + stopWatch.elapsed(java.util.concurrent.TimeUnit.MILLISECONDS)); stopWatch.reset(); stopWatch.start(); mutator.mutate(p); if (i % printInterval == 0) { LOG.info("Put " + printInterval + "/" + stopWatch.elapsed(java.util.concurrent.TimeUnit.MILLISECONDS)); stopWatch.reset(); stopWatch.start();
@Override protected long readMicros() { return stopwatch.elapsed(MICROSECONDS); }
public long elapsedNanos() { return stopwatch.elapsed(NANOSECONDS); }
ImmutableMap<Service, Long> startupTimes() { List<Entry<Service, Long>> loadTimes; monitor.enter(); try { loadTimes = Lists.newArrayListWithCapacity(startupTimers.size()); // N.B. There will only be an entry in the map if the service has started for (Entry<Service, Stopwatch> entry : startupTimers.entrySet()) { Service service = entry.getKey(); Stopwatch stopWatch = entry.getValue(); if (!stopWatch.isRunning() && !(service instanceof NoOpService)) { loadTimes.add(Maps.immutableEntry(service, stopWatch.elapsed(MILLISECONDS))); } } } finally { monitor.leave(); } Collections.sort( loadTimes, Ordering.natural() .onResultOf( new Function<Entry<Service, Long>, Long>() { @Override public Long apply(Map.Entry<Service, Long> input) { return input.getValue(); } })); return ImmutableMap.copyOf(loadTimes); }
/** * Ensure passed zookeeper is connected. * @param timeout Time to wait on established Connection */ public static ZooKeeper ensureConnectedZooKeeper(ZooKeeper zookeeper, int timeout) throws ZooKeeperConnectionException { if (zookeeper.getState().isConnected()) { return zookeeper; } Stopwatch stopWatch = Stopwatch.createStarted(); // Make sure we are connected before we hand it back. while(!zookeeper.getState().isConnected()) { Threads.sleep(1); if (stopWatch.elapsed(TimeUnit.MILLISECONDS) > timeout) { throw new ZooKeeperConnectionException("Failed connect after waiting " + stopWatch.elapsed(TimeUnit.MILLISECONDS) + "ms (zk session timeout); " + zookeeper); } } return zookeeper; } }
protected void testHdfsStreaming(Path filename) throws IOException { byte[] buf = new byte[1024]; FileSystem fs = filename.getFileSystem(getConf()); // read the file from start to finish Stopwatch fileOpenTimer = Stopwatch.createUnstarted(); Stopwatch streamTimer = Stopwatch.createUnstarted(); fileOpenTimer.start(); FSDataInputStream in = fs.open(filename); fileOpenTimer.stop(); long totalBytes = 0; streamTimer.start(); while (true) { int read = in.read(buf); if (read < 0) { break; } totalBytes += read; } streamTimer.stop(); double throughput = (double)totalBytes / streamTimer.elapsed(TimeUnit.SECONDS); System.out.println("HDFS streaming: "); System.out.println("total time to open: " + fileOpenTimer.elapsed(TimeUnit.MILLISECONDS) + " ms"); System.out.println("total time to read: " + streamTimer.elapsed(TimeUnit.MILLISECONDS) + " ms"); System.out.println("total bytes: " + totalBytes + " bytes (" + StringUtils.humanReadableInt(totalBytes) + ")"); System.out.println("throghput : " + StringUtils.humanReadableInt((long)throughput) + "B/s"); }
@Override protected int doWork() throws Exception { generateRegionsAndServers(); String methodName = "roundRobinAssignment"; LOG.info("Calling " + methodName); Stopwatch watch = Stopwatch.createStarted(); loadBalancer.roundRobinAssignment(regions, servers); System.out.print(formatResults(methodName, watch.elapsed(TimeUnit.MILLISECONDS))); methodName = "retainAssignment"; LOG.info("Calling " + methodName); watch.reset().start(); loadBalancer.retainAssignment(regionServerMap, servers); System.out.print(formatResults(methodName, watch.elapsed(TimeUnit.MILLISECONDS))); methodName = "balanceCluster"; LOG.info("Calling " + methodName); watch.reset().start(); loadBalancer.balanceCluster(serverRegionMap); System.out.print(formatResults(methodName, watch.elapsed(TimeUnit.MILLISECONDS))); return EXIT_SUCCESS; }
protected void testHdfsStreaming(Path filename) throws IOException { byte[] buf = new byte[1024]; FileSystem fs = filename.getFileSystem(getConf()); // read the file from start to finish Stopwatch fileOpenTimer = Stopwatch.createUnstarted(); Stopwatch streamTimer = Stopwatch.createUnstarted(); fileOpenTimer.start(); FSDataInputStream in = fs.open(filename); fileOpenTimer.stop(); long totalBytes = 0; streamTimer.start(); while (true) { int read = in.read(buf); if (read < 0) { break; } totalBytes += read; } streamTimer.stop(); double throughput = (double)totalBytes / streamTimer.elapsed(TimeUnit.SECONDS); System.out.println("HDFS streaming: "); System.out.println("total time to open: " + fileOpenTimer.elapsed(TimeUnit.MILLISECONDS) + " ms"); System.out.println("total time to read: " + streamTimer.elapsed(TimeUnit.MILLISECONDS) + " ms"); System.out.println("total bytes: " + totalBytes + " bytes (" + StringUtils.humanReadableInt(totalBytes) + ")"); System.out.println("throghput : " + StringUtils.humanReadableInt((long)throughput) + "B/s"); }
double throughput = (double)totalBytes / scanTimer.elapsed(TimeUnit.SECONDS); double throughputRows = (double)numRows / scanTimer.elapsed(TimeUnit.SECONDS); double throughputCells = (double)numCells / scanTimer.elapsed(TimeUnit.SECONDS); scanOpenTimer.elapsed(TimeUnit.MILLISECONDS) + " ms"); System.out.println("total time to scan: " + scanTimer.elapsed(TimeUnit.MILLISECONDS) + " ms");
double throughput = (double)totalBytes / scanTimer.elapsed(TimeUnit.SECONDS); double throughputRows = (double)numRows / scanTimer.elapsed(TimeUnit.SECONDS); double throughputCells = (double)numCells / scanTimer.elapsed(TimeUnit.SECONDS); scanOpenTimer.elapsed(TimeUnit.MILLISECONDS) + " ms"); System.out.println("total time to scan: " + scanTimer.elapsed(TimeUnit.MILLISECONDS) + " ms");