Refine search
@Override public void persist(final Committer committer) { final Stopwatch runExecStopwatch = Stopwatch.createStarted(); appenderator.persistAll(committer); final long startDelay = runExecStopwatch.elapsed(TimeUnit.MILLISECONDS); metrics.incrementPersistBackPressureMillis(startDelay); if (startDelay > WARN_DELAY) { log.warn("Ingestion was throttled for [%,d] millis because persists were pending.", startDelay); } runExecStopwatch.stop(); }
private void createNewLogFileIfNeeded() throws IOException { if (LogCopier.this.destFs.exists(this.destLogFile) && (this.watch.elapsed(TimeUnit.MINUTES) > LogCopier.this.maxMinutesPerLogFile || LogCopier.this.destFs.getFileStatus(this.destLogFile).getLen() > LogCopier.this.maxBytesPerLogFile)) { HadoopUtils.renamePath(LogCopier.this.destFs, this.destLogFile, new Path(this.destLogFile.toString() + "." + System.currentTimeMillis())); this.watch.reset(); this.watch.start(); } }
class TimeTest2 { public static void main(String[] args) { Stopwatch timer = new Stopwatch().start(); long total = 0; for (int i = 0; i < 10000000; i++) { total += i; } timer.stop(); System.out.println(timer.getElapsedTime()); } }
public AbstractStreamOp(String stream, OpStatsLogger statsLogger, Long checksum, Feature checksumDisabledFeature) { this.stream = stream; this.opStatsLogger = statsLogger; // start here in case the operation is failed before executing. stopwatch.reset().start(); this.checksum = checksum; this.checksumDisabledFeature = checksumDisabledFeature; }
private void assertUninterruptibleDrained(BlockingQueue<Object> q) { assertEquals(0, Queues.drainUninterruptibly(q, ImmutableList.of(), 0, 10, MILLISECONDS)); // but does the wait actually occurs? @SuppressWarnings("unused") // go/futurereturn-lsc Future<?> possiblyIgnoredError = threadPool.submit(new Interrupter(currentThread())); Stopwatch timer = Stopwatch.createStarted(); Queues.drainUninterruptibly(q, newArrayList(), 1, 10, MILLISECONDS); assertThat(timer.elapsed(MILLISECONDS)).isAtLeast(10L); // wait for interrupted status and clear it while (!Thread.interrupted()) { Thread.yield(); } }
throw new ISE("No sink for identifier: %s", identifier); final List<FireHydrant> hydrants = Lists.newArrayList(sink); currentHydrants.put(identifier.toString(), hydrants.size()); numPersistedRows += sink.getNumRowsInMemory(); final Stopwatch runExecStopwatch = Stopwatch.createStarted(); final Stopwatch persistStopwatch = Stopwatch.createStarted(); final ListenableFuture<Object> future = persistExecutor.submit( new ThreadRenamingCallable<Object>(threadName) final long startDelay = runExecStopwatch.elapsed(TimeUnit.MILLISECONDS); metrics.incrementPersistBackPressureMillis(startDelay); if (startDelay > WARN_DELAY) { log.warn("Ingestion was throttled for [%,d] millis because persists were pending.", startDelay); runExecStopwatch.stop(); resetNextFlush();
private final Stopwatch stopwatch = Stopwatch.createStarted(clockTicker); private int nextStream; private int numTriedStreams = 0;
public ChunkMesh generateMesh(ChunkView chunkView, int meshHeight, int verticalOffset) { PerformanceMonitor.startActivity("GenerateMesh"); ChunkMesh mesh = new ChunkMesh(bufferPool); final Stopwatch watch = Stopwatch.createStarted(); for (int x = 0; x < ChunkConstants.SIZE_X; x++) { for (int z = 0; z < ChunkConstants.SIZE_Z; z++) { for (int y = verticalOffset; y < verticalOffset + meshHeight; y++) { Block block = chunkView.getBlock(x, y, z); if (block != null && block.getMeshGenerator() != null) { block.getMeshGenerator().generateChunkMesh(chunkView, mesh, x, y, z); } } } } watch.stop(); mesh.setTimeToGenerateBlockVertices((int) watch.elapsed(TimeUnit.MILLISECONDS)); watch.reset().start(); generateOptimizedBuffers(chunkView, mesh); watch.stop(); mesh.setTimeToGenerateOptimizedBuffers((int) watch.elapsed(TimeUnit.MILLISECONDS)); statVertexArrayUpdateCount++; PerformanceMonitor.endActivity(); return mesh; }
public void testRunWithTimeout_goodRunnableWithEnoughTime() throws Exception { Stopwatch stopwatch = Stopwatch.createStarted(); service.runWithTimeout(GOOD_RUNNABLE, ENOUGH_MS, MILLISECONDS); assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(DELAY_MS, ENOUGH_MS)); }
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(Entry<Service, Long> input) { return input.getValue(); } })); return ImmutableMap.copyOf(loadTimes); }
@Override public void run() { Stopwatch sw = Stopwatch.createUnstarted(); Map<String, GarbageCollectorMXBean> gcBeanMapBeforeSleep = getGarbageCollectorMXBeans(); while (true) { sw.reset().start(); try { Thread.sleep(mGcSleepIntervalMs); } catch (InterruptedException ie) { LOG.warn(ie.getStackTrace()); return; } long extraTime = sw.elapsed(TimeUnit.MILLISECONDS) - mGcSleepIntervalMs; mTotalExtraTimeMs += extraTime; Map<String, GarbageCollectorMXBean> gcBeanMapAfterSleep = getGarbageCollectorMXBeans(); if (extraTime > mWarnThresholdMs) { mInfoTimeExceeded++; mWarnTimeExceeded++; LOG.warn(formatLogString(extraTime, gcBeanMapBeforeSleep, gcBeanMapAfterSleep)); } else if (extraTime > mInfoThresholdMs) { mInfoTimeExceeded++; LOG.info(formatLogString( extraTime, gcBeanMapBeforeSleep, gcBeanMapAfterSleep)); } gcBeanMapBeforeSleep = gcBeanMapAfterSleep; } } }
public void testElapsed_multipleSegments() { stopwatch.start(); ticker.advance(9); stopwatch.stop(); ticker.advance(16); stopwatch.start(); assertEquals(9, stopwatch.elapsed(NANOSECONDS)); ticker.advance(25); assertEquals(34, stopwatch.elapsed(NANOSECONDS)); stopwatch.stop(); ticker.advance(36); assertEquals(34, stopwatch.elapsed(NANOSECONDS)); }
private void testEnumeratorValues(String file) throws Exception { InputStream is = new FileInputStream(file); ArrayList<String> str = loadStrings(is); TrieDictionaryBuilder<String> b = newDictBuilder(str); TrieDictionary<String> dict = b.build(0); System.out.println("Dictionary size for file " + file + " is " + dict.getSize()); Stopwatch sw = new Stopwatch(); sw.start(); List<String> values1 = dict.enumeratorValuesByParent(); System.out.println("By iterating id visit the time cost " + sw.elapsed(TimeUnit.MILLISECONDS) + " ms"); sw.reset(); sw.start(); List<String> values2 = dict.enumeratorValues(); System.out.println("By pre-order visit the time cost " + sw.elapsed(TimeUnit.MILLISECONDS) + " ms"); sw.stop(); assertEquals(Sets.newHashSet(values1), Sets.newHashSet(values2)); }
public void testPutWithNoWait() { Stopwatch stopwatch = Stopwatch.createStarted(); BlockingQueue<String> queue = new ArrayBlockingQueue<>(999); putUninterruptibly(queue, ""); assertTimeNotPassed(stopwatch, LONG_DELAY_MS); assertEquals("", queue.peek()); }
public void testReset_whileRunning() { ticker.advance(1); stopwatch.start(); assertEquals(0, stopwatch.elapsed(NANOSECONDS)); ticker.advance(2); assertEquals(2, stopwatch.elapsed(NANOSECONDS)); stopwatch.reset(); assertFalse(stopwatch.isRunning()); ticker.advance(3); assertEquals(0, stopwatch.elapsed(NANOSECONDS)); }
public void profileRun() Stopwatch watch = Stopwatch.createUnstarted(); LoadQueuePeonTester fromPeon = new LoadQueuePeonTester(); LoadQueuePeonTester toPeon = new LoadQueuePeonTester(); .build(); DruidCoordinatorBalancerTester tester = new DruidCoordinatorBalancerTester(coordinator); watch.start(); DruidCoordinatorRuntimeParams balanceParams = tester.run(params); System.out.println(watch.stop());
@Test public void createDirectChildrenCacheStressTest() { Stopwatch sw = new Stopwatch(); sw.start(); Set<Long> cuboidSet = generateMassCuboidSet(); System.out.println("Time elapsed for creating sorted cuboid list: " + sw.elapsedMillis()); sw.reset(); sw.start(); checkDirectChildrenCacheStressTest(CuboidStatsUtil.createDirectChildrenCache(cuboidSet)); System.out.println("Time elapsed for creating direct children cache: " + sw.elapsedMillis()); sw.stop(); }