use of org.apache.commons.lang.time.StopWatch in project archiva by apache.
the class DefaultRepositoryStatisticsManager method getLastStatistics.
@Override
public RepositoryStatistics getLastStatistics(MetadataRepository metadataRepository, String repositoryId) throws MetadataRepositoryException {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
// TODO: consider a more efficient implementation that directly gets the last one from the content repository
List<String> scans = metadataRepository.getMetadataFacets(repositoryId, DefaultRepositoryStatistics.FACET_ID);
if (scans == null) {
return null;
}
Collections.sort(scans);
if (!scans.isEmpty()) {
String name = scans.get(scans.size() - 1);
RepositoryStatistics repositoryStatistics = RepositoryStatistics.class.cast(metadataRepository.getMetadataFacet(repositoryId, RepositoryStatistics.FACET_ID, name));
stopWatch.stop();
log.debug("time to find last RepositoryStatistics: {} ms", stopWatch.getTime());
return repositoryStatistics;
} else {
return null;
}
}
use of org.apache.commons.lang.time.StopWatch in project eol-globi-data by jhpoelen.
the class NameResolver method resolveNames.
public void resolveNames(Long batchSize) {
StopWatch watchForEntireRun = new StopWatch();
watchForEntireRun.start();
StopWatch watchForBatch = new StopWatch();
watchForBatch.start();
Long count = 0L;
Index<Node> studyIndex = graphService.index().forNodes("studies");
IndexHits<Node> studies = studyIndex.query("title", "*");
for (Node studyNode : studies) {
final Study study1 = new StudyNode(studyNode);
final Iterable<Relationship> specimens = NodeUtil.getSpecimens(study1);
for (Relationship collected : specimens) {
SpecimenNode specimen = new SpecimenNode(collected.getEndNode());
final Relationship classifiedAs = specimen.getUnderlyingNode().getSingleRelationship(NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS), Direction.OUTGOING);
if (classifiedAs == null) {
final Relationship describedAs = specimen.getUnderlyingNode().getSingleRelationship(NodeUtil.asNeo4j(RelTypes.ORIGINALLY_DESCRIBED_AS), Direction.OUTGOING);
final TaxonNode describedAsTaxon = new TaxonNode(describedAs.getEndNode());
try {
if (taxonFilter.shouldInclude(describedAsTaxon)) {
Taxon resolvedTaxon = taxonIndex.getOrCreateTaxon(describedAsTaxon);
if (resolvedTaxon != null) {
specimen.classifyAs(resolvedTaxon);
}
}
} catch (NodeFactoryException e) {
LOG.warn("failed to create taxon with name [" + describedAsTaxon.getName() + "] and id [" + describedAsTaxon.getExternalId() + "]", e);
} finally {
count++;
if (count % batchSize == 0) {
watchForBatch.stop();
final long duration = watchForBatch.getTime();
if (duration > 0) {
LOG.info("resolved batch of [" + batchSize + "] names in " + getProgressMsg(batchSize, duration));
}
watchForBatch.reset();
watchForBatch.start();
}
}
}
}
}
studies.close();
watchForEntireRun.stop();
LOG.info("resolved [" + count + "] names in " + getProgressMsg(count, watchForEntireRun.getTime()));
}
use of org.apache.commons.lang.time.StopWatch in project eol-globi-data by jhpoelen.
the class LinkUtil method doTimedLink.
public static void doTimedLink(Linker linker) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
String linkName = Linker.class.getSimpleName();
LOG.info(linkName + " started...");
try {
linker.link();
} finally {
stopWatch.stop();
LOG.info(linkName + " completed in [" + stopWatch.getTime() / 1000 + "]s");
}
}
use of org.apache.commons.lang.time.StopWatch in project eol-globi-data by jhpoelen.
the class TaxonInteractionIndexer method createTaxonInteractions.
public void createTaxonInteractions(Map<Fun.Tuple3<Long, String, Long>, Long> taxonInteractions) {
StopWatch watchForEntireRun = new StopWatch();
watchForEntireRun.start();
long count = 0;
Transaction tx = null;
for (Fun.Tuple3<Long, String, Long> uniqueTaxonInteraction : taxonInteractions.keySet()) {
if (count % 1000 == 0) {
finalizeTx(tx);
tx = graphService.beginTx();
}
final Node sourceTaxon = graphService.getNodeById(uniqueTaxonInteraction.a);
final Node targetTaxon = graphService.getNodeById(uniqueTaxonInteraction.c);
if (sourceTaxon != null && targetTaxon != null) {
final InteractType relType = InteractType.valueOf(uniqueTaxonInteraction.b);
final Long interactionCount = taxonInteractions.get(uniqueTaxonInteraction);
createInteraction(sourceTaxon, targetTaxon, relType, false, interactionCount);
createInteraction(targetTaxon, sourceTaxon, InteractType.inverseOf(relType), true, interactionCount);
}
count++;
}
finalizeTx(tx);
watchForEntireRun.stop();
LOG.info("created [" + count + "] taxon interactions in " + getProgressMsg(count, watchForEntireRun.getTime()));
}
use of org.apache.commons.lang.time.StopWatch in project elephant-bird by twitter.
the class TimeProtoConversions method main.
/**
* @param args
* @throws ExecException
*/
public static void main(String[] args) throws ExecException {
int iterations = 100000;
ProtobufToPig protoConv = new ProtobufToPig();
for (int i = 0; i < iterations; i++) {
Person proto = Fixtures.buildPersonProto();
Tuple t = protoConv.toTuple(proto);
t.get(0);
t = new ProtobufTuple(proto);
t.get(0);
}
StopWatch timer = new StopWatch();
timer.start();
for (int i = 0; i < iterations; i++) {
Person proto = Fixtures.buildPersonProto();
Tuple t = protoConv.toTuple(proto);
t.get(0);
}
timer.split();
System.err.println(timer.getSplitTime());
timer.reset();
timer.start();
for (int i = 0; i < iterations; i++) {
Person proto = Fixtures.buildPersonProto();
Tuple t = new ProtobufTuple(proto);
t.get(0);
}
timer.split();
System.err.println(timer.getSplitTime());
}
Aggregations