本文整理汇总了Java中com.google.common.base.Stopwatch.createUnstarted方法的典型用法代码示例。如果您正苦于以下问题:Java Stopwatch.createUnstarted方法的具体用法?Java Stopwatch.createUnstarted怎么用?Java Stopwatch.createUnstarted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.base.Stopwatch
的用法示例。
在下文中一共展示了Stopwatch.createUnstarted方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ignoredTimedTransMult
import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
public void ignoredTimedTransMult() {
Stopwatch watch = Stopwatch.createUnstarted();
DenseMatrix dense = new DenseMatrix(1000, 1000);
int[][] nz = Utilities.getRowPattern(dense.numRows(),
dense.numColumns(), 100);
Utilities.rowPopulate(dense, nz);
log.info("created matrices");
Matrix sparse = new LinkedSparseMatrix(dense.numRows(),
dense.numColumns());
sparse.set(dense);
for (Matrix m : Lists.newArrayList(dense, sparse)) {
log.info("starting " + m.getClass());
Matrix t = new DenseMatrix(m);
Matrix o = new DenseMatrix(dense.numRows(), dense.numColumns());
log.info("warming up " + m.getClass() + " " + o.getClass());
for (int i = 0; i < 10; i++)
m.transAmult(t, o);
log.info("starting " + m.getClass() + " " + o.getClass());
watch.start();
for (int i = 0; i < 100; i++)
m.transAmult(t, o);
watch.stop();
log.info(m.getClass() + " " + o.getClass() + " " + watch);
}
}
示例2: pushConfigWithConflictingVersionRetries
import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
private synchronized boolean pushConfigWithConflictingVersionRetries(final ConfigSnapshotHolder configSnapshotHolder) throws ConfigSnapshotFailureException {
ConflictingVersionException lastException;
Stopwatch stopwatch = Stopwatch.createUnstarted();
do {
//TODO wait untill all expected modules are in yangStoreService, do we even need to with yangStoreService instead on netconfOperationService?
String idForReporting = configSnapshotHolder.toString();
SortedSet<String> expectedCapabilities = checkNotNull(configSnapshotHolder.getCapabilities(),
"Expected capabilities must not be null - %s, check %s", idForReporting,
configSnapshotHolder.getClass().getName());
// wait max time for required capabilities to appear
waitForCapabilities(expectedCapabilities, idForReporting);
try {
if(!stopwatch.isRunning()) {
stopwatch.start();
}
return pushConfig(configSnapshotHolder);
} catch (final ConflictingVersionException e) {
lastException = e;
LOG.info("Conflicting version detected, will retry after timeout");
sleep();
}
} while (stopwatch.elapsed(TimeUnit.MILLISECONDS) < conflictingVersionTimeoutMillis);
throw new IllegalStateException("Max wait for conflicting version stabilization timeout after " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + " ms",
lastException);
}
示例3: StopwatchThread
import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
StopwatchThread(final Metrics metrics, final SystemInfo systemInfo, final ProcessWatcherActorInput message) {
this.metrics = metrics;
this.systemInfo = systemInfo;
this.message = message;
stopwatch = Stopwatch.createUnstarted();
}
示例4: readPage
import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
public void readPage(PageHeader pageHeader, int compressedSize, int uncompressedSize, ArrowBuf dest) throws IOException {
Stopwatch timer = Stopwatch.createUnstarted();
long timeToRead;
long start = inputStream.getPos();
if (parentColumnReader.columnChunkMetaData.getCodec() == CompressionCodecName.UNCOMPRESSED) {
timer.start();
dataReader.loadPage(dest, compressedSize);
timeToRead = timer.elapsed(TimeUnit.MICROSECONDS);
this.updateStats(pageHeader, "Page Read", start, timeToRead, compressedSize, uncompressedSize);
} else {
final ArrowBuf compressedData = allocateTemporaryBuffer(compressedSize);
try {
timer.start();
dataReader.loadPage(compressedData, compressedSize);
timeToRead = timer.elapsed(TimeUnit.MICROSECONDS);
timer.reset();
this.updateStats(pageHeader, "Page Read", start, timeToRead, compressedSize, compressedSize);
start = inputStream.getPos();
timer.start();
codecFactory.getDecompressor(parentColumnReader.columnChunkMetaData
.getCodec()).decompress(compressedData.nioBuffer(0, compressedSize), compressedSize,
dest.nioBuffer(0, uncompressedSize), uncompressedSize);
timeToRead = timer.elapsed(TimeUnit.MICROSECONDS);
this.updateStats(pageHeader, "Decompress", start, timeToRead, compressedSize, uncompressedSize);
} finally {
compressedData.release();
}
}
}
示例5: ignoredTimedMult
import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
public void ignoredTimedMult() {
Stopwatch watch = Stopwatch.createUnstarted();
DenseMatrix dense = new DenseMatrix(1000, 1000);
int[][] nz = Utilities.getRowPattern(dense.numRows(),
dense.numColumns(), 100);
Utilities.rowPopulate(dense, nz);
log.info("created matrices");
Matrix sparse = new LinkedSparseMatrix(dense.numRows(),
dense.numColumns());
sparse.set(dense);
for (Matrix m : Lists.newArrayList(dense, sparse)) {
log.info("starting " + m.getClass());
Matrix t = new DenseMatrix(m);
t.transpose();
Matrix o = new DenseMatrix(dense.numRows(), dense.numColumns());
log.info("warming up " + m.getClass() + " " + o.getClass());
for (int i = 0; i < 10; i++)
m.mult(t, o);
log.info("starting " + m.getClass() + " " + o.getClass());
watch.start();
for (int i = 0; i < 100; i++)
m.mult(t, o);
watch.stop();
log.info(m.getClass() + " " + o.getClass() + " " + watch);
}
}
示例6: MessageTracker
import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
@VisibleForTesting
MessageTracker(final Class<?> expectedMessageClass, final long expectedArrivalIntervalInMillis,
final Ticker ticker) {
Preconditions.checkArgument(expectedArrivalIntervalInMillis >= 0);
this.expectedMessageClass = Preconditions.checkNotNull(expectedMessageClass);
this.expectedArrivalInterval = MILLISECONDS.toNanos(expectedArrivalIntervalInMillis);
this.ticker = Preconditions.checkNotNull(ticker);
this.expectedMessageWatch = Stopwatch.createUnstarted(ticker);
this.currentMessageContext = new CurrentMessageContext();
}
示例7: getShareStopwatch
import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
private static Stopwatch getShareStopwatch() {
Stopwatch share = CacheUtil.cache(TimingUtil.class, Thread.currentThread(), () -> Stopwatch.createUnstarted());
return share.isRunning() ? Stopwatch.createUnstarted() : share;
}
示例8: submitQuery
import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
public int submitQuery(DremioClient client, String plan, String type, String format, int width) throws Exception {
String[] queries;
QueryType queryType;
type = type.toLowerCase();
switch (type) {
case "sql":
queryType = QueryType.SQL;
queries = plan.trim().split(";");
break;
case "logical":
queryType = QueryType.LOGICAL;
queries = new String[]{ plan };
break;
case "physical":
queryType = QueryType.PHYSICAL;
queries = new String[]{ plan };
break;
default:
System.out.println("Invalid query type: " + type);
return -1;
}
Format outputFormat;
format = format.toLowerCase();
switch (format) {
case "csv":
outputFormat = Format.CSV;
break;
case "tsv":
outputFormat = Format.TSV;
break;
case "table":
outputFormat = Format.TABLE;
break;
default:
System.out.println("Invalid format type: " + format);
return -1;
}
Stopwatch watch = Stopwatch.createUnstarted();
for (String query : queries) {
AwaitableUserResultsListener listener =
new AwaitableUserResultsListener(new PrintingResultsListener(client.getConfig(), outputFormat, width));
watch.start();
client.runQuery(queryType, query, listener);
int rows = listener.await();
System.out.println(String.format("%d record%s selected (%f seconds)", rows, rows > 1 ? "s" : "", (float) watch.elapsed(TimeUnit.MILLISECONDS) / (float) 1000));
if (query != queries[queries.length - 1]) {
System.out.println();
}
watch.stop();
watch.reset();
}
return 0;
}
示例9: next
import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
@Override
public int next() {
int recordCount;
final Stopwatch copyWatch = Stopwatch.createUnstarted();
final Stopwatch filterWatch = Stopwatch.createUnstarted();
delegate.allocate(fieldVectorMap);
// keep reading until the delegate reader is done or the filter doesn't filter everything
while ((recordCount = delegate.next()) > 0) {
if (mutator.isSchemaChanged()) {
// report the schema change to the caller but keep reading from the reader
// This is similar to the behavior of ScanOperator.outputData()
externalCallback.doWork();
}
filterWatch.start();
recordCount = filter.filterBatch(recordCount);
filterWatch.stop();
if (recordCount > 0) {
break;
}
// filter excluded all rows, we need to call the delegate reader again
readerOutput.allocateNew();
}
copyOutput.allocateNew();
copyWatch.start();
int copied = copier.copyRecords(0, recordCount);
copyWatch.stop();
if (copied != recordCount) { // copier may return earlier if it runs out of memory
throw UserException.memoryError().message("Ran out of memory while trying to copy the records.").build(logger);
}
for (TransferPair t : copierToOutputTransfers) {
t.transfer();
}
context.getStats().addLongStat(ScanOperator.Metric.COPY_MS, copyWatch.elapsed(TimeUnit.MILLISECONDS));
context.getStats().addLongStat(ScanOperator.Metric.FILTER_MS, filterWatch.elapsed(TimeUnit.MILLISECONDS));
return recordCount;
}