@Override public void retain(String indexName, IndexSet indexSet) { final Stopwatch sw = Stopwatch.createStarted(); indices.close(indexName); auditEventSender.success(AuditActor.system(nodeId), ES_INDEX_RETENTION_CLOSE, ImmutableMap.of( "index_name", indexName, "retention_strategy", this.getClass().getCanonicalName() )); LOG.info("Finished index retention strategy [close] for index <{}> in {}ms.", indexName, sw.stop().elapsed(TimeUnit.MILLISECONDS)); }
@Override public IDBlock call() { Stopwatch running = Stopwatch.createStarted(); try { if (stopRequested) { log.debug("Aborting ID block retrieval on partition({})-namespace({}) after " + "graceful shutdown was requested, exec time {}, exec+q time {}", partition, idNamespace, running.stop(), alive.stop()); throw new TitanException("ID block retrieval aborted by caller"); } IDBlock idBlock = idAuthority.getIDBlock(partition, idNamespace, renewTimeout); log.debug("Retrieved ID block from authority on partition({})-namespace({}), " + "exec time {}, exec+q time {}", partition, idNamespace, running.stop(), alive.stop()); Preconditions.checkArgument(idBlock!=null && idBlock.numIds()>0); return idBlock; } catch (BackendException e) { throw new TitanException("Could not acquire new ID block from storage", e); } catch (IDPoolExhaustedException e) { return ID_POOL_EXHAUSTION; } } }
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; }
private void benchmarkIteration(Iterator<RevCommit> commits) { NumberFormat numberFormat = NumberFormat.getInstance(Locale.ENGLISH); Stopwatch sw = Stopwatch.createStarted(); sw.reset().start(); int c = 0; while (commits.hasNext()) { c++; commits.next(); } sw.stop(); System.err.println("Iterated " + numberFormat.format(c) + " commits in " + sw.toString()); }
@Override public void finish(CuboidResult result) { Stopwatch stopwatch = new Stopwatch().start(); int nRetries = 0; while (!outputQueue.offer(result)) { nRetries++; long sleepTime = stopwatch.elapsedMillis(); if (sleepTime > 3600000L) { stopwatch.stop(); throw new RuntimeException( "OutputQueue Full. Cannot offer to the output queue after waiting for one hour!!! Current queue size: " + outputQueue.size()); } logger.warn("OutputQueue Full. Queue size: " + outputQueue.size() + ". Total sleep time : " + sleepTime + ", and retry count : " + nRetries); try { Thread.sleep(5000L); } catch (InterruptedException e) { throw new RuntimeException(e); } } stopwatch.stop(); } }
Transaction transaction = null; List<Event> events = Lists.newArrayListWithExpectedSize(this.batchSize); Stopwatch watch = new Stopwatch().start(); try { transaction = channel.getTransaction(); logger.error(String.format("Time taken to process [%s] events was [%s] seconds",events.size(),watch.stop().elapsedTime(TimeUnit.SECONDS))); if( transaction != null ) { transaction.close();
@Override public void retain(String indexName, IndexSet indexSet) { final Stopwatch sw = Stopwatch.createStarted(); indices.delete(indexName); auditEventSender.success(AuditActor.system(nodeId), ES_INDEX_RETENTION_DELETE, ImmutableMap.of( "index_name", indexName, "retention_strategy", this.getClass().getCanonicalName() )); LOG.info("Finished index retention strategy [delete] for index <{}> in {}ms.", indexName, sw.stop().elapsed(TimeUnit.MILLISECONDS)); }
Stopwatch stopwatch = Stopwatch.createStarted(); try { if (null == lastDLSN) { reader = FutureUtils.result(dlm.openAsyncLogReader(lastDLSN)); long elapsedMs = stopwatch.elapsed(TimeUnit.MICROSECONDS); openReaderStats.registerSuccessfulEvent(elapsedMs); logger.info("It took {} ms to position the reader to transaction id = {}, dlsn = {}", lastTxId, lastDLSN); } catch (IOException ioe) { openReaderStats.registerFailedEvent(stopwatch.elapsed(TimeUnit.MICROSECONDS)); logger.warn("Failed to create reader for stream {} reading from tx id = {}, dlsn = {}.", new Object[] { streamName, lastTxId, lastDLSN }); while (true) { try { stopwatch.start(); records = FutureUtils.result(reader.readBulk(batchSize)); long elapsedMicros = stopwatch.stop().elapsed(TimeUnit.MICROSECONDS); blockingReadStats.registerSuccessfulEvent(elapsedMicros); if (!records.isEmpty()) {
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)); }
@Override public IDBlock call() { Stopwatch running = Stopwatch.createStarted(); try { if (stopRequested) { log.debug("Aborting ID block retrieval on partition({})-namespace({}) after " + "graceful shutdown was requested, exec time {}, exec+q time {}", partition, idNamespace, running.stop(), alive.stop()); throw new JanusGraphException("ID block retrieval aborted by caller"); } IDBlock idBlock = idAuthority.getIDBlock(partition, idNamespace, renewTimeout); log.debug("Retrieved ID block from authority on partition({})-namespace({}), " + "exec time {}, exec+q time {}", partition, idNamespace, running.stop(), alive.stop()); Preconditions.checkArgument(idBlock!=null && idBlock.numIds()>0); return idBlock; } catch (BackendException e) { throw new JanusGraphException("Could not acquire new ID block from storage", e); } catch (IDPoolExhaustedException e) { return ID_POOL_EXHAUSTION; } } }
@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(); }
public void testQueueDeletedRecentlyRetriesWhen60DoesntTry() { SQSErrorRetryHandler retry = new SQSErrorRetryHandler(createMock(AWSUtils.class), createMock(BackoffLimitedRetryHandler.class), ImmutableSet.<String> of(), 60, 100); HttpCommand command = createHttpCommandForFailureCount(60); Stopwatch watch = new Stopwatch().start(); assertFalse(retry.shouldRetryRequestOnError(command, response, error)); assertEquals(command.getFailureCount(), 61); assertTrue(watch.stop().elapsedTime(TimeUnit.MILLISECONDS) < 100); }
@Override protected void shutDown() throws Exception { for (Periodical periodical : periodicals.getAllStoppedOnGracefulShutdown()) { LOG.info("Shutting down periodical [{}].", periodical.getClass().getCanonicalName()); Stopwatch s = Stopwatch.createStarted(); // Cancel future executions. Map<Periodical,ScheduledFuture> futures = periodicals.getFutures(); if (futures.containsKey(periodical)) { futures.get(periodical).cancel(false); s.stop(); LOG.info("Shutdown of periodical [{}] complete, took <{}ms>.", periodical.getClass().getCanonicalName(), s.elapsed(TimeUnit.MILLISECONDS)); } else { LOG.error("Could not find periodical [{}] in futures list. Not stopping execution.", periodical.getClass().getCanonicalName()); } } } }
Stopwatch stopwatch = Stopwatch.createStarted(); try { reader = dlm.getInputStream(lastTxId); long elapsedMs = stopwatch.elapsed(TimeUnit.MICROSECONDS); openReaderStats.registerSuccessfulEvent(elapsedMs); logger.info("It took {} ms to position the reader to transaction id {}", lastTxId); } catch (IOException ioe) { openReaderStats.registerFailedEvent(stopwatch.elapsed(TimeUnit.MICROSECONDS)); logger.warn("Failed to create reader for stream {} reading from {}.", streamName, lastTxId); while (true) { try { stopwatch.start(); record = reader.readNext(nonBlocking); if (null != record) { long elapsedMicros = stopwatch.stop().elapsed(TimeUnit.MICROSECONDS); if (nonBlocking) { nonBlockingReadStats.registerSuccessfulEvent(elapsedMicros);