List of usage examples for com.google.common.base Stopwatch createStarted
@CheckReturnValue public static Stopwatch createStarted()
From source file:org.apache.drill.exec.store.parquet.stat.ParquetMetaStatCollector.java
@Override public Map<SchemaPath, ColumnStatistics> collectColStat(Set<SchemaPath> fields) { Stopwatch timer = Stopwatch.createStarted(); // map from column to ColumnMetadata final Map<SchemaPath, Metadata.ColumnMetadata> columnMetadataMap = new HashMap<>(); // map from column name to column statistics. final Map<SchemaPath, ColumnStatistics> statMap = new HashMap<>(); for (final Metadata.ColumnMetadata columnMetadata : columnMetadataList) { SchemaPath schemaPath = SchemaPath.getCompoundPath(columnMetadata.getName()); columnMetadataMap.put(schemaPath, columnMetadata); }//from w ww . j a v a2s . c o m for (final SchemaPath schemaPath : fields) { final PrimitiveType.PrimitiveTypeName primitiveType; final OriginalType originalType; final Metadata.ColumnMetadata columnMetadata = columnMetadataMap.get(schemaPath); if (columnMetadata != null) { final Object min = columnMetadata.getMinValue(); final Object max = columnMetadata.getMaxValue(); final Long numNull = columnMetadata.getNulls(); primitiveType = this.parquetTableMetadata.getPrimitiveType(columnMetadata.getName()); originalType = this.parquetTableMetadata.getOriginalType(columnMetadata.getName()); final Integer repetitionLevel = this.parquetTableMetadata .getRepetitionLevel(columnMetadata.getName()); statMap.put(schemaPath, getStat(min, max, numNull, primitiveType, originalType, repetitionLevel)); } else { final String columnName = schemaPath.getRootSegment().getPath(); if (implicitColValues.containsKey(columnName)) { TypeProtos.MajorType type = Types.required(TypeProtos.MinorType.VARCHAR); Statistics stat = new BinaryStatistics(); stat.setNumNulls(0); byte[] val = implicitColValues.get(columnName).getBytes(); stat.setMinMaxFromBytes(val, val); statMap.put(schemaPath, new ColumnStatistics(stat, type)); } } } if (logger.isDebugEnabled()) { logger.debug("Took {} ms to column statistics for row group", timer.elapsed(TimeUnit.MILLISECONDS)); } return statMap; }
From source file:edu.illinois.keshmesh.detector.Main.java
private static BasicAnalysisData initBytecodeAnalysis(IJavaProject javaProject, Reporter reporter, ConfigurationOptions configurationOptions) throws WALAInitializationException { KeshmeshCGModel model;// www. java2 s . c o m try { String exclusionsFileName = FileProvider .getFileFromPlugin(Activator.getDefault(), "EclipseDefaultExclusions.txt").getAbsolutePath(); model = new KeshmeshCGModel(javaProject, exclusionsFileName, configurationOptions.getObjectSensitivityLevel()); Stopwatch stopWatch = Stopwatch.createStarted(); model.buildGraph(); stopWatch.stop(); reporter.report(new KeyValuePair("CALL_GRAPH_CONSTRUCTION_TIME_IN_MILLISECONDS", String.valueOf(stopWatch.elapsed(TimeUnit.MILLISECONDS)))); reportEntryPointStatistics(reporter, model.getEntryPoints()); dumpEntryPoints(model.getEntryPoints()); } catch (Exception e) { throw new Exceptions.WALAInitializationException(e); } CallGraph callGraph = model.getGraph(); reportCallGraphStatistics(reporter, callGraph); PointerAnalysis pointerAnalysis = model.getPointerAnalysis(); HeapModel heapModel = pointerAnalysis.getHeapModel(); BasicHeapGraph heapGraph = new BasicHeapGraph(pointerAnalysis, callGraph); if (configurationOptions.shouldDumpHeapGraph()) { dumpHeapGraph(heapGraph); } reporter.report( new KeyValuePair("NUMBER_OF_NODES_OF_HEAP_GRAPH", String.valueOf(heapGraph.getNumberOfNodes()))); if (!hasShownGraphs) { try { DisplayUtils.displayGraph(callGraph); DisplayUtils.displayGraph(heapGraph); hasShownGraphs = true; } catch (WalaException e) { throw new WALAInitializationException(e); } } IClassHierarchy classHierarchy = model.getClassHierarchy(); reporter.report(new KeyValuePair("NUMBER_OF_CLASSES", String.valueOf(classHierarchy.getNumberOfClasses()))); return new BasicAnalysisData(classHierarchy, callGraph, pointerAnalysis, heapModel, heapGraph); }
From source file:com.isotrol.impe3.core.engine.AbstractHTMLRenderingEngine.java
final HTMLFragment timed(final Ok result, final String name, final UUID cipId, final HTMLFragment f) { if (f == null) { return null; }//from w w w. ja va2 s . c o m return new HTMLFragment() { public void writeTo(OutputStream output, Charset charset) throws IOException { final Stopwatch w = Stopwatch.createStarted(); try { f.writeTo(output, charset); } finally { final long t = w.elapsed(TimeUnit.MILLISECONDS); if (t > 150) { logger.warn(String.format("CIP [%s]-[%s] took [%d] ms to render [%s]", cipId, result.getCips().get(cipId).getCip().getDefinition().getType(), t, name)); } } } }; }
From source file:org.lenskit.knn.item.model.ItemwiseBuildContextProvider.java
/** * Constructs and returns a new ItemItemBuildContext. * * @return a new ItemItemBuildContext./*from w w w . j a va 2s . c o m*/ */ @Override public ItemItemBuildContext get() { logger.info("constructing build context"); Stopwatch timer = Stopwatch.createStarted(); logger.debug("using normalizer {}", normalizer); logger.debug("Building item data"); Long2ObjectMap<LongList> userItems = new Long2ObjectOpenHashMap<>(1000); Long2ObjectMap<SparseVector> itemVectors = new Long2ObjectOpenHashMap<>(1000); ObjectStream<ItemEventCollection<Event>> itemObjectStream = itemEventDAO.streamEventsByItem(); try { for (ItemEventCollection<Event> item : itemObjectStream) { if (logger.isTraceEnabled()) { logger.trace("processing {} ratings for item {}", item.size(), item); } List<Rating> ratings = FluentIterable.from(item).filter(Rating.class).toList(); MutableSparseVector vector = MutableSparseVector.create(Ratings.itemRatingVector(ratings)); normalizer.normalize(item.getItemId(), vector, vector); for (VectorEntry e : vector) { long user = e.getKey(); LongList uis = userItems.get(user); if (uis == null) { // lists are nice and fast, we only see each item once uis = new LongArrayList(); userItems.put(user, uis); } uis.add(item.getItemId()); } itemVectors.put(item.getItemId(), vector.freeze()); } } finally { itemObjectStream.close(); } Long2ObjectMap<LongSortedSet> userItemSets = new Long2ObjectOpenHashMap<>(); for (Long2ObjectMap.Entry<LongList> entry : userItems.long2ObjectEntrySet()) { userItemSets.put(entry.getLongKey(), LongUtils.packedSet(entry.getValue())); } SortedKeyIndex items = SortedKeyIndex.fromCollection(itemVectors.keySet()); SparseVector[] itemData = new SparseVector[items.size()]; for (int i = 0; i < itemData.length; i++) { long itemId = items.getKey(i); itemData[i] = itemVectors.get(itemId); } timer.stop(); logger.info("finished build context for {} items in {}", items.size(), timer); return new ItemItemBuildContext(items, itemData, userItemSets); }
From source file:org.smartdeveloperhub.curator.connector.LoggedConnectorFuture.java
@Override public Enrichment get() throws InterruptedException, ExecutionException { final Stopwatch waiting = Stopwatch.createStarted(); LOGGER.trace("Waiting for acknowledgment..."); final Enrichment reply = this.delegate.get(); waiting.stop();//from w w w. j a v a 2 s . c om logAcknowledgeReception(waiting); return reply; }
From source file:org.grouplens.lenskit.knn.item.model.ItemItemModelBuilder.java
@Override public SimilarityMatrixModel get() { logger.debug("building item-item model"); logger.debug("using similarity function {}", itemSimilarity); logger.debug("similarity function is {}", itemSimilarity.isSparse() ? "sparse" : "non-sparse"); logger.debug("similarity function is {}", itemSimilarity.isSymmetric() ? "symmetric" : "non-symmetric"); LongSortedSet allItems = buildContext.getItems(); Long2ObjectMap<ScoredItemAccumulator> rows = makeAccumulators(allItems); final int nitems = allItems.size(); LongIterator outer = allItems.iterator(); Stopwatch timer = Stopwatch.createStarted(); int ndone = 0; while (outer.hasNext()) { ndone += 1;/* w w w. j a va 2 s . c o m*/ final long itemId1 = outer.nextLong(); if (logger.isTraceEnabled()) { logger.trace("computing similarities for item {} ({} of {})", itemId1, ndone, nitems); } SparseVector vec1 = buildContext.itemVector(itemId1); LongIterator itemIter = neighborStrategy.neighborIterator(buildContext, itemId1, itemSimilarity.isSymmetric()); ScoredItemAccumulator row = rows.get(itemId1); while (itemIter.hasNext()) { long itemId2 = itemIter.nextLong(); if (itemId1 != itemId2) { SparseVector vec2 = buildContext.itemVector(itemId2); double sim = itemSimilarity.similarity(itemId1, vec1, itemId2, vec2); if (threshold.retain(sim)) { row.put(itemId2, sim); if (itemSimilarity.isSymmetric()) { rows.get(itemId2).put(itemId1, sim); } } } } if (logger.isDebugEnabled() && ndone % 100 == 0) { logger.debug("computed {} of {} model rows ({}s/row)", ndone, nitems, String.format("%.3f", timer.elapsed(TimeUnit.MILLISECONDS) * 0.001 / ndone)); } } timer.stop(); logger.info("built model for {} items in {}", ndone, timer); return new SimilarityMatrixModel(finishRows(rows)); }
From source file:org.apache.bookkeeper.proto.ReadEntryProcessorV3.java
public ReadEntryProcessorV3(Request request, Channel channel, BookieRequestProcessor requestProcessor, ExecutorService fenceThreadPool) { super(request, channel, requestProcessor); requestProcessor.onReadRequestStart(channel); this.readRequest = request.getReadRequest(); this.ledgerId = readRequest.getLedgerId(); this.entryId = readRequest.getEntryId(); if (RequestUtils.isFenceRequest(this.readRequest)) { this.readStats = requestProcessor.getRequestStats().getFenceReadEntryStats(); this.reqStats = requestProcessor.getRequestStats().getFenceReadRequestStats(); } else if (readRequest.hasPreviousLAC()) { this.readStats = requestProcessor.getRequestStats().getLongPollReadStats(); this.reqStats = requestProcessor.getRequestStats().getLongPollReadRequestStats(); } else {//from w w w .j a v a 2s .c o m this.readStats = requestProcessor.getRequestStats().getReadEntryStats(); this.reqStats = requestProcessor.getRequestStats().getReadRequestStats(); } this.fenceThreadPool = fenceThreadPool; lastPhaseStartTime = Stopwatch.createStarted(); }
From source file:com.minestellar.core.MinestellarCore.java
@EventHandler public void preInit(FMLPreInitializationEvent event) { Stopwatch stopwatch = Stopwatch.createStarted(); new ConfigManagerCore(new File(event.getModConfigurationDirectory(), "Minestellar/blocks.cfg")); CoreBlocks.init();/*from ww w. ja v a 2 s.com*/ CoreItems.init(); GameRegistry.registerBlock(new TestDataBlock("testDataBlock"), "testDataBlock"); MinestellarCore.proxy.preInit(event); log.info("PreInitialization Completed in " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + " ms."); }
From source file:io.dropwizard.revolver.core.RevolverCommand.java
@SuppressWarnings("unchecked") public ResponseType execute(final RequestType request) throws RevolverExecutionException, TimeoutException { final CommandHandlerConfigType apiConfiguration = this.apiConfigurations.get(request.getApi()); if (null == apiConfiguration) { throw new RevolverExecutionException(RevolverExecutionException.Type.BAD_REQUEST, "No api spec defined for key: " + request.getApi()); }/* w ww .j ava 2s . c o m*/ final RequestType normalizedRequest = RevolverCommandHelper.normalize(request); final TraceInfo traceInfo = normalizedRequest.getTrace(); addContextInfo(request, traceInfo); final Stopwatch watch = Stopwatch.createStarted(); String errorMessage = null; try { ResponseType response = (ResponseType) new RevolverCommandHandler( RevolverCommandHelper.setter(this, request.getApi()), this.context, this, normalizedRequest) .execute(); log.debug("Command response: " + response); return response; } catch (Throwable t) { val rootCause = ExceptionUtils.getRootCause(t); if (rootCause instanceof TimeoutException) { throw (TimeoutException) rootCause; } errorMessage = rootCause.getLocalizedMessage(); throw new RevolverExecutionException(RevolverExecutionException.Type.SERVICE_ERROR, rootCause); } finally { publishTrace(Trace.builder().caller(this.clientConfiguration.getClientName()) .service(this.serviceConfiguration.getService()).api(apiConfiguration.getApi()) .duration(watch.stop().elapsed(TimeUnit.MILLISECONDS)) .transactionId(traceInfo.getTransactionId()).requestId(traceInfo.getRequestId()) .parentRequestId(traceInfo.getParentRequestId()).timestamp(traceInfo.getTimestamp()) .attributes(traceInfo.getAttributes()).error(!Strings.isNullOrEmpty(errorMessage)) .errorReason(errorMessage).build()); } }
From source file:de.metas.ui.web.view.ViewsRepository.java
private static void truncateTable(final String tableName) { final Stopwatch stopwatch = Stopwatch.createStarted(); try {/*from w w w. j a v a 2s .c om*/ final int no = DB.executeUpdateEx("TRUNCATE TABLE " + tableName, ITrx.TRXNAME_NoneNotNull); logger.info("Deleted {} records(all) from table {} (Took: {})", no, tableName, stopwatch); } catch (final Exception ex) { logger.warn("Failed deleting all from {} (Took: {})", tableName, stopwatch, ex); } }