本文整理了Java中org.apache.commons.lang3.time.StopWatch.getTime()
方法的一些代码示例,展示了StopWatch.getTime()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StopWatch.getTime()
方法的具体详情如下:
包路径:org.apache.commons.lang3.time.StopWatch
类名称:StopWatch
方法名:getTime
[英]Get the time on the stopwatch.
This is either the time between the start and the moment this method is called, or the amount of time between start and stop.
[中]记下秒表上的时间。
这是启动和调用此方法之间的时间,或者是启动和停止之间的时间。
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* <p>
* Gets a summary of the time that the stopwatch recorded as a string.
* </p>
*
* <p>
* The format used is ISO 8601-like, <i>hours</i>:<i>minutes</i>:<i>seconds</i>.<i>milliseconds</i>.
* </p>
*
* @return the time as a String
*/
@Override
public String toString() {
return DurationFormatUtils.formatDurationHMS(getTime());
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testStopWatchGetWithTimeUnit() {
// Create a mock StopWatch with a time of 2:59:01.999
final StopWatch watch = createMockStopWatch(
TimeUnit.HOURS.toNanos(2)
+ TimeUnit.MINUTES.toNanos(59)
+ TimeUnit.SECONDS.toNanos(1)
+ TimeUnit.MILLISECONDS.toNanos(999));
assertEquals(2L, watch.getTime(TimeUnit.HOURS));
assertEquals(179L, watch.getTime(TimeUnit.MINUTES));
assertEquals(10741L, watch.getTime(TimeUnit.SECONDS));
assertEquals(10741999L, watch.getTime(TimeUnit.MILLISECONDS));
}
代码示例来源:origin: apache/hbase
@Override public Void call() throws Exception {
ZooKeeper zooKeeper = null;
try {
zooKeeper = new ZooKeeper(host, timeout, EmptyWatcher.instance);
Stat exists = zooKeeper.exists(znode, false);
StopWatch stopwatch = new StopWatch();
stopwatch.start();
zooKeeper.getData(znode, false, exists);
stopwatch.stop();
sink.publishReadTiming(znode, host, stopwatch.getTime());
} catch (KeeperException | InterruptedException e) {
sink.publishReadFailure(znode, host);
} finally {
if (zooKeeper != null) {
zooKeeper.close();
}
}
return null;
}
}
代码示例来源:origin: apache/flink
sw.start();
while (!isclosed) {
if (sw.getTime() > asyncTimeout) {
break;
long newLen = fs.getFileStatus(partPath).getLen();
while (newLen != validLength) {
if (sw.getTime() > asyncTimeout) {
break;
代码示例来源:origin: apache/flink
sw.start();
while (!isclosed) {
if (sw.getTime() > asyncTimeout) {
break;
long newLen = fs.getFileStatus(partPath).getLen();
while (newLen != bucketState.currentFileValidLength) {
if (sw.getTime() > asyncTimeout) {
break;
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testStopWatchSimpleGet() {
final StopWatch watch = new StopWatch();
assertEquals(0, watch.getTime());
assertEquals("00:00:00.000", watch.toString());
watch.start();
try {
Thread.sleep(500);
} catch (final InterruptedException ex) {
}
assertTrue(watch.getTime() < 2000);
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testLang315() {
final StopWatch watch = new StopWatch();
watch.start();
try {
Thread.sleep(200);
} catch (final InterruptedException ex) {
}
watch.suspend();
final long suspendTime = watch.getTime();
try {
Thread.sleep(200);
} catch (final InterruptedException ex) {
}
watch.stop();
final long totalTime = watch.getTime();
assertTrue(suspendTime == totalTime);
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testStopWatchSimple() {
final StopWatch watch = new StopWatch();
watch.start();
try {
Thread.sleep(550);
} catch (final InterruptedException ex) {
}
watch.stop();
final long time = watch.getTime();
assertEquals(time, watch.getTime());
assertTrue(time >= 500);
assertTrue(time < 700);
watch.reset();
assertEquals(0, watch.getTime());
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testStopWatchSuspend() {
final StopWatch watch = new StopWatch();
watch.start();
try {
Thread.sleep(550);
} catch (final InterruptedException ex) {
}
watch.suspend();
final long suspendTime = watch.getTime();
try {
Thread.sleep(550);
} catch (final InterruptedException ex) {
}
watch.resume();
try {
Thread.sleep(550);
} catch (final InterruptedException ex) {
}
watch.stop();
final long totalTime = watch.getTime();
assertTrue(suspendTime >= 500);
assertTrue(suspendTime < 700);
assertTrue(totalTime >= 1000);
assertTrue(totalTime < 1300);
}
代码示例来源:origin: apache/hbase
private static void timerTests(final CellBlockBuilder builder, final int count, final int size,
final Codec codec, final CompressionCodec compressor) throws IOException {
final int cycles = 1000;
StopWatch timer = new StopWatch();
timer.start();
for (int i = 0; i < cycles; i++) {
timerTest(builder, timer, count, size, codec, compressor, false);
}
timer.stop();
LOG.info("Codec=" + codec + ", compression=" + compressor + ", sized=" + false + ", count="
+ count + ", size=" + size + ", + took=" + timer.getTime() + "ms");
timer.reset();
timer.start();
for (int i = 0; i < cycles; i++) {
timerTest(builder, timer, count, size, codec, compressor, true);
}
timer.stop();
LOG.info("Codec=" + codec + ", compression=" + compressor + ", sized=" + true + ", count="
+ count + ", size=" + size + ", + took=" + timer.getTime() + "ms");
}
代码示例来源:origin: apache/usergrid
private CandidateResults testQuery( final SearchEdge scope, final SearchTypes searchTypes,
final String queryString,
final int num ) {
StopWatch timer = new StopWatch();
timer.start();
CandidateResults candidateResults = entityIndex.search( scope, searchTypes, queryString, 1000, 0, false );
timer.stop();
assertEquals(num, candidateResults.size());
logger.debug("Query time {}ms", timer.getTime());
return candidateResults;
}
代码示例来源:origin: apache/hbase
sink.publishReadTiming(tableName.getNameAsString(), serverName, stopWatch.getTime());
} catch (TableNotFoundException tnfe) {
LOG.error("Table may be deleted", tnfe);
代码示例来源:origin: apache/usergrid
logger.info( "Total time to write {} entries {}ms", limit, timer.getTime() );
timer.reset();
logger.info( "Total time to read {} entries {}ms", limit, timer.getTime() );
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testStopWatchSplit() {
final StopWatch watch = new StopWatch();
watch.start();
try {
Thread.sleep(550);
} catch (final InterruptedException ex) {
}
watch.split();
final long splitTime = watch.getSplitTime();
final String splitStr = watch.toSplitString();
try {
Thread.sleep(550);
} catch (final InterruptedException ex) {
}
watch.unsplit();
try {
Thread.sleep(550);
} catch (final InterruptedException ex) {
}
watch.stop();
final long totalTime = watch.getTime();
assertEquals("Formatted split string not the correct length",
splitStr.length(), 12);
assertTrue(splitTime >= 500);
assertTrue(splitTime < 700);
assertTrue(totalTime >= 1500);
assertTrue(totalTime < 1900);
}
代码示例来源:origin: apache/usergrid
private void insertJsonBlob( List<Object> sampleJson, EntityIndexBatch batch, String entityType,
IndexEdge indexEdge, final int max, final int startIndex ) throws IOException {
int count = 0;
StopWatch timer = new StopWatch();
timer.start();
if ( startIndex > 0 ) {
for ( int i = 0; i < startIndex; i++ ) {
sampleJson.remove( 0 );
}
}
for ( Object o : sampleJson ) {
Map<String, Object> item = ( Map<String, Object> ) o;
Entity entity = new Entity( entityType );
entity = EntityIndexMapUtils.fromMap( entity, item );
EntityUtils.setVersion( entity, UUIDGenerator.newTimeUUID() );
entity.setField( new UUIDField( IndexingUtils.ENTITY_ID_FIELDNAME, UUID.randomUUID() ) );
batch.index( indexEdge, entity );
if ( ++count > max ) {
break;
}
}
timer.stop();
logger.info( "Total time to index {} entries {}ms, average {}ms/entry",
new Object[] { count, timer.getTime(), timer.getTime() / count } );
}
代码示例来源:origin: apache/usergrid
logger.info( "Total time to write {} entries {} ms", writeLimit, timer.getTime() );
timer.reset();
logger.info( "Total time to read {} entries {} ms", readCount, timer.getTime() );
代码示例来源:origin: apache/hbase
this.readWriteLatency.add(stopWatch.getTime());
sink.publishReadTiming(serverName, region, column, stopWatch.getTime());
} catch (Exception e) {
sink.publishReadFailure(serverName, region, column, e);
代码示例来源:origin: apache/usergrid
logger.info( "Total time to write {} entries {}ms", limit, timer.getTime());
timer.reset();
logger.info( "Total time to read {} entries {}ms", limit, timer.getTime());
代码示例来源:origin: apache/usergrid
logger.debug("Query time {}ms", timer.getTime());
代码示例来源:origin: apache/usergrid
logger.debug( "Query time {}ms", timer.getTime() );
内容来源于网络,如有侵权,请联系作者删除!