List of usage examples for com.google.common.base Stopwatch elapsed
@CheckReturnValue public long elapsed(TimeUnit desiredUnit)
From source file:cosmos.impl.CosmosImpl.java
@Override public void addResult(Store id, Record<?> queryResult) throws Exception { checkNotNull(queryResult);/*w w w . ja v a2 s .co m*/ Stopwatch sw = new Stopwatch().start(); try { addResults(id, Single.<Record<?>>create(queryResult)); } finally { sw.stop(); id.tracer().addTiming("Cosmos:addResult", sw.elapsed(TimeUnit.MILLISECONDS)); } }
From source file:org.terasology.rendering.primitives.ChunkTessellator.java
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++) { Biome biome = chunkView.getBiome(x, y, z); Block block = chunkView.getBlock(x, y, z); if (block != null && !block.isInvisible()) { generateBlockVertices(chunkView, mesh, x, y, z, biome); }/* w w w. ja v a2 s. c o m*/ } } } 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; }
From source file:com.xiaomi.linden.service.CoreLindenServiceImpl.java
@Override public Future<Response> executeCommand(final String command) { final Stopwatch sw = Stopwatch.createStarted(); return instanceExecutorPool.apply(new Function0<Response>() { @Override//from www .j ava2s . co m public Response apply() { LOGGER.info("Receive command {}", command); Response response = null; try { long eps = sw.elapsed(TimeUnit.MILLISECONDS); if (eps > 10) { LOGGER.warn("Warning: instanceExecutorPool took " + eps + "ms to start executeCommand."); if (eps > instanceFuturePoolWaitTimeout) { response = ResponseUtils.buildFailedResponse( "Waiting time is too long, " + eps + "ms in instance future pool"); return response; } } response = lindenCore.executeCommand(command); } catch (Exception e) { String errorStackInfo = Throwables.getStackTraceAsString(e); response = ResponseUtils.buildFailedResponse(errorStackInfo); } finally { if (response.isSuccess()) { LOGGER.info("executeCommand succeeded, command: {}, cost: {} ms.", command, sw.elapsed(TimeUnit.MILLISECONDS)); } else { LOGGER.error("executeCommand failed, content: {}, cost: {} ms.", command, sw.elapsed(TimeUnit.MILLISECONDS)); } return response; } } }); }
From source file:com.xiaomi.linden.service.CoreLindenServiceImpl.java
@Override public Future<LindenResult> handleClusterSearchRequest(final String bql) { final Stopwatch sw = Stopwatch.createStarted(); return clusterExecutorPool.apply(new Function0<LindenResult>() { @Override//from w w w . j a v a 2s . co m public LindenResult apply() { LindenResult result = null; String logTag = null; try { long eps = sw.elapsed(TimeUnit.MILLISECONDS); if (eps > 10) { LOGGER.warn("Warning: clusterExecutorPool took " + eps + "ms to start handleClusterSearchRequest."); if (eps > clusterFuturePoolWaitTimeout) { result = buildLindenFailedResult( "Waiting time is too long, " + eps + "ms in cluster future pool"); return result; } } LindenRequest request = bqlCompiler.compile(bql); if (request.isSetSearchRequest()) { LindenSearchRequest searchRequest = request.getSearchRequest(); searchRequest.setOriginQuery(bql); result = lindenCluster.search(searchRequest); if (result.isSuccess()) { logTag = "search"; } else { logTag = "failureSearch"; } } else { result = new LindenResult().setSuccess(false).setError("invalid search Bql"); logTag = "invalidSearchBql"; } } catch (Exception e) { String errorStackInfo = Throwables.getStackTraceAsString(e); result = buildLindenFailedResult(errorStackInfo); logTag = "exceptionalSearchBql"; } finally { metricsManager.time(sw.elapsed(TimeUnit.NANOSECONDS), logTag); result.setCost((int) sw.elapsed(TimeUnit.MILLISECONDS)); if (result.isSuccess()) { LOGGER.info("Cluster search request succeeded bql: {}, hits: {}, cost: {} ms.", bql, result.getHitsSize(), result.getCost()); } else { LOGGER.error("Cluster search request failed bql: {}, error: {}, cost: {} ms.", bql, result.getError(), result.getCost()); } return result; } } }); }
From source file:com.github.ibole.infrastructure.security.jwt.jose4j.EcJose4jTokenAuthenticator.java
/** * Create Refresh Token./*w w w. ja va 2s .c om*/ */ @Override public String createRefreshToken(JwtObject claimObj) throws TokenHandlingException { Preconditions.checkArgument(claimObj != null, "Parameter claimObj cannot be null"); final Stopwatch stopwatch = Stopwatch.createStarted(); String token = null; try { token = JoseUtils.createJwtWithECKey(claimObj, (EllipticCurveJsonWebKey) ecJsonWebKey); getRedisTemplate().hset(getRefreshTokenKey(claimObj.getLoginId()), Constants.REFRESH_TOKEN, token); getRedisTemplate().hset(getRefreshTokenKey(claimObj.getLoginId()), Constants.CLIENT_ID, claimObj.getClientId()); getRedisTemplate().expire(getRefreshTokenKey(claimObj.getLoginId()), claimObj.getTtlSeconds()); } catch (JoseException ex) { logger.error("Error happened when generating the jwt token.", ex); throw new TokenHandlingException(ex); } String elapsedString = Long.toString(stopwatch.elapsed(TimeUnit.MILLISECONDS)); logger.debug("Create refresh token elapsed time: {} ms", elapsedString); return token; }
From source file:ca.uhn.fhir.jpa.term.BaseHapiTerminologySvc.java
@Transactional(propagation = Propagation.REQUIRED) @Override//from w w w.ja v a 2 s . c o m public Set<TermConcept> findCodesAbove(Long theCodeSystemResourcePid, Long theCodeSystemVersionPid, String theCode) { Stopwatch stopwatch = Stopwatch.createStarted(); TermConcept concept = fetchLoadedCode(theCodeSystemResourcePid, theCodeSystemVersionPid, theCode); if (concept == null) { return Collections.emptySet(); } Set<TermConcept> retVal = new HashSet<TermConcept>(); retVal.add(concept); fetchParents(concept, retVal); ourLog.info("Fetched {} codes above code {} in {}ms", new Object[] { retVal.size(), theCode, stopwatch.elapsed(TimeUnit.MILLISECONDS) }); return retVal; }
From source file:ca.uhn.fhir.jpa.term.BaseHapiTerminologySvc.java
@Transactional(propagation = Propagation.REQUIRED) @Override/*from w w w. j a va 2 s.com*/ public Set<TermConcept> findCodesBelow(Long theCodeSystemResourcePid, Long theCodeSystemVersionPid, String theCode) { Stopwatch stopwatch = Stopwatch.createStarted(); TermConcept concept = fetchLoadedCode(theCodeSystemResourcePid, theCodeSystemVersionPid, theCode); if (concept == null) { return Collections.emptySet(); } Set<TermConcept> retVal = new HashSet<TermConcept>(); retVal.add(concept); fetchChildren(concept, retVal); ourLog.info("Fetched {} codes below code {} in {}ms", new Object[] { retVal.size(), theCode, stopwatch.elapsed(TimeUnit.MILLISECONDS) }); return retVal; }