List of usage examples for org.springframework.util StopWatch start
public void start() throws IllegalStateException
From source file:org.springframework.statemachine.recipes.support.RunnableAction.java
@Override public final void execute(StateContext<String, String> context) { if (!shouldExecute(id, context)) { return;/* w w w. j a va 2 s. c o m*/ } StopWatch watch = new StopWatch(); String logId = (id == null ? "" : (" id=" + id)); log.info("Executing runnable" + logId); if (log.isDebugEnabled()) { watch.start(); } try { onPreExecute(id, context); runnable.run(); onSuccess(id, context); } catch (Exception e) { onError(id, context, e); } finally { onPostExecute(id, context); } if (log.isDebugEnabled()) { watch.stop(); log.debug("Runnable execution took " + watch.getTotalTimeMillis() + " ms" + logId); } }
From source file:ubic.gemma.core.tasks.visualization.DifferentialExpressionSearchTaskImpl.java
/** * Retrieve the details (contrasts) for results which meet the criterion. (PVALUE_CONTRAST_SELECT_THRESHOLD). * Requires a database hit./*from w w w.j a va 2 s . c o m*/ * * @param diffExResults results * @return map */ private Map<Long, ContrastsValueObject> getDetailsForContrasts( Collection<DiffExprGeneSearchResult> diffExResults) { StopWatch timer = new StopWatch(); timer.start(); List<Long> resultsWithContrasts = new ArrayList<>(); for (DiffExprGeneSearchResult r : diffExResults) { if (r.getResultId() == null) { // it is a dummy result. It means there is no result for this gene in this resultset. continue; } /* * this check will not be needed if we only store the 'good' results, but we do store everything. */ // Here I am trying to avoid fetching them when there is no hope that the results will be interesting. if (r instanceof MissingResult || r instanceof NonRetainedResult || r .getCorrectedPvalue() > DifferentialExpressionSearchTaskImpl.PVALUE_CONTRAST_SELECT_THRESHOLD) { // Then it won't have contrasts; no need to fetch. continue; } resultsWithContrasts.add(r.getResultId()); } Map<Long, ContrastsValueObject> detailedResults = new HashMap<>(); if (!resultsWithContrasts.isEmpty()) { // uses a left join so it will have all the results. detailedResults = differentialExpressionResultService .loadContrastDetailsForResults(resultsWithContrasts); } timer.stop(); if (timer.getTotalTimeMillis() > 1) { DifferentialExpressionSearchTaskImpl.log.info("Fetch contrasts for " + resultsWithContrasts.size() + " results: " + timer.getTotalTimeMillis() + "ms"); } return detailedResults; }
From source file:ubic.gemma.persistence.util.monitor.MonitorAdvice.java
@Around("@annotation(ubic.gemma.persistence.util.monitor.Monitored)") public Object profile(ProceedingJoinPoint pjp) throws Throwable { StopWatch stopWatch = new StopWatch(); stopWatch.start(); Object retVal = pjp.proceed(); stopWatch.stop();/*from ww w .j a va2s . c o m*/ log.info(pjp.getSignature().toString() + " took " + stopWatch.getLastTaskTimeMillis() + "ms."); return retVal; }
From source file:ubic.gemma.tasks.visualization.DifferentialExpressionSearchTaskImpl.java
/** * Staging for getting the diff ex results. * //from w w w .j ava2s . c o m * @param resultSets to be searched * @param geneIds to be searched * @param searchResult holds the results */ private void fetchDifferentialExpressionResults(List<ExpressionAnalysisResultSet> resultSets, List<Long> geneIds, DifferentialExpressionGenesConditionsValueObject searchResult) { Map<ExpressionAnalysisResultSet, Collection<Long>> resultSetIdsToArrayDesignsUsed = new HashMap<ExpressionAnalysisResultSet, Collection<Long>>(); StopWatch timer = new StopWatch(); timer.start(); // DATABASE CALL HERE, but should be quite fast. for (ExpressionAnalysisResultSet rs : resultSets) { resultSetIdsToArrayDesignsUsed.put(rs, EntityUtils.getIds(eeService.getArrayDesignsUsed(rs.getAnalysis().getExperimentAnalyzed()))); } timer.stop(); if (timer.getTotalTimeMillis() > 100) { log.info("Fetch array designs used: " + timer.getTotalTimeMillis() + "ms"); } fetchDifferentialExpressionResults(resultSetIdsToArrayDesignsUsed, geneIds, searchResult); }
From source file:ubic.gemma.tasks.visualization.DifferentialExpressionSearchTaskImpl.java
/** * Retrieve the details (contrasts) for results which meet the criterion. (PVALUE_CONTRAST_SELECT_THRESHOLD) * /*w w w.j a v a 2 s.c o m*/ * @param geneToProbeResult * @return */ private Map<Long, ContrastsValueObject> getDetailsForContrasts( Collection<DiffExprGeneSearchResult> diffExResults) { StopWatch timer = new StopWatch(); timer.start(); List<Long> resultsWithContrasts = new ArrayList<Long>(); for (DiffExprGeneSearchResult r : diffExResults) { if (r.getResultId() == null) { // it is a dummy result. It means there is no result for this gene in this resultset. continue; } /* * this check will not be needed if we only store the 'good' results? */ // Here I am trying to avoid fetching them when there is no hope that the results will be interesting. if (r instanceof MissingResult || r instanceof NonRetainedResult || r.getCorrectedPvalue() > PVALUE_CONTRAST_SELECT_THRESHOLD) { // Then it won't have contrasts; no need to fetch. continue; } resultsWithContrasts.add(r.getResultId()); } Map<Long, ContrastsValueObject> detailedResults = new HashMap<Long, ContrastsValueObject>(); if (!resultsWithContrasts.isEmpty()) { // uses a left join so it will have all the results. detailedResults = differentialExpressionResultService .loadContrastDetailsForResults(resultsWithContrasts); } timer.stop(); if (timer.getTotalTimeMillis() > 1) { log.info("Fetch contrasts for " + resultsWithContrasts.size() + " results: " + timer.getTotalTimeMillis() + "ms"); } return detailedResults; }
From source file:uk.ac.ebi.atlas.experimentimport.analyticsindex.baseline.BaselineAnalyticsIndexerService.java
public int index(BaselineExperiment experiment) { String experimentAccession = experiment.getAccession(); ExperimentType experimentType = experiment.getType(); String defaultQueryFactorType = experiment.getExperimentalFactors().getDefaultQueryFactorType(); ExperimentDesign experimentDesign = experiment.getExperimentDesign(); ImmutableMap<String, String> ensemblSpeciesGroupedByAssayGroupId = SpeciesGrouper .buildEnsemblSpeciesGroupedByAssayGroupId(experiment); ImmutableSetMultimap<String, String> ontologyTermIdsByAssayAccession = expandOntologyTerms( experimentDesign.getAllOntologyTermIdsByAssayAccession()); ImmutableSetMultimap<String, String> conditionSearchTermsByAssayGroupId = buildConditionSearchTermsByAssayGroupId( experiment, ontologyTermIdsByAssayAccession); checkArgument(StringUtils.isNotBlank(defaultQueryFactorType)); LOGGER.info("Start indexing " + experimentAccession); StopWatch stopWatch = new StopWatch(getClass().getSimpleName()); stopWatch.start(); //TODO: move this to another class ObjectInputStream<BaselineAnalytics> inputStream = (experimentType == ExperimentType.PROTEOMICS_BASELINE) ? proteomicsBaselineAnalyticsInputStreamFactory.create(experimentAccession) : baselineAnalyticsInputStreamFactory.create(experimentAccession); int count = indexRnaSeqBaselineExperimentAnalytics(experimentAccession, experimentType, defaultQueryFactorType, conditionSearchTermsByAssayGroupId, ensemblSpeciesGroupedByAssayGroupId, inputStream);//ww w . ja va 2s . co m stopWatch.stop(); LOGGER.info(String.format("Done indexing %s, indexed %,d documents in %s seconds", experimentAccession, count, stopWatch.getTotalTimeSeconds())); return count; }
From source file:uk.ac.ebi.atlas.search.baseline.BaselineExperimentAssayGroupSearchService.java
public SortedSet<BaselineExperimentAssayGroup> query(Set<String> geneIds, Optional<String> condition, Optional<String> species) { LOGGER.info(String.format("<query> geneIds=%s, condition=%s", Joiner.on(", ").join(geneIds), condition)); StopWatch stopWatch = new StopWatch(getClass().getSimpleName()); stopWatch.start(); String conditionString = condition.isPresent() ? condition.get() : ""; String speciesString = species.isPresent() ? species.get() : ""; Optional<ImmutableSet<IndexedAssayGroup>> indexedAssayGroups = fetchAssayGroupsForCondition( conditionString);//from w w w . j a v a 2 s . co m SetMultimap<String, String> assayGroupsWithExpressionByExperiment = baselineExperimentAssayGroupsDao .fetchExperimentAssayGroupsWithNonSpecificExpression(indexedAssayGroups, Optional.of(geneIds)); SortedSet<BaselineExperimentAssayGroup> baselineExperimentAssayGroups = searchedForConditionButGotNoResults( conditionString, indexedAssayGroups) ? emptySortedSet() : buildResults(assayGroupsWithExpressionByExperiment, !StringUtils.isBlank(conditionString), speciesString); stopWatch.stop(); LOGGER.info(String.format("<query> %s results, took %s seconds", baselineExperimentAssayGroups.size(), stopWatch.getTotalTimeSeconds())); return baselineExperimentAssayGroups; }
From source file:uk.ac.ebi.atlas.search.baseline.BaselineExperimentAssayGroupSearchService.java
@Deprecated public SortedSet<BaselineExperimentAssayGroup> query(String geneQuery, String condition, String specie, boolean isExactMatch) { LOGGER.info(String.format("<query> geneQuery=%s, condition=%s", geneQuery, condition)); StopWatch stopWatch = new StopWatch(getClass().getSimpleName()); stopWatch.start(); Optional<ImmutableSet<IndexedAssayGroup>> indexedAssayGroups = fetchAssayGroupsForCondition(condition); String species = StringUtils.isNotBlank(specie) ? specie : ""; //TODO: move outside into caller, because this is called twice, here and in DiffAnalyticsSearchService Optional<Set<String>> geneIds = solrQueryService.expandGeneQueryIntoGeneIds(geneQuery, species, isExactMatch);//ww w . j a v a 2 s . c o m SetMultimap<String, String> assayGroupsWithExpressionByExperiment = baselineExperimentAssayGroupsDao .fetchExperimentAssayGroupsWithNonSpecificExpression(indexedAssayGroups, geneIds); boolean conditionSearch = !isEmpty(indexedAssayGroups); SortedSet<BaselineExperimentAssayGroup> baselineExperimentAssayGroups = Sets.newTreeSet(); if (conditionSearch || StringUtils.isNotEmpty(geneQuery) && StringUtils.isEmpty(condition)) { baselineExperimentAssayGroups = buildResults(assayGroupsWithExpressionByExperiment, conditionSearch, species); } stopWatch.stop(); LOGGER.info(String.format("<query> %s results, took %s seconds", baselineExperimentAssayGroups.size(), stopWatch.getTotalTimeSeconds())); return baselineExperimentAssayGroups; }