本文整理了Java中org.apache.commons.lang3.time.StopWatch.start()
方法的一些代码示例,展示了StopWatch.start()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StopWatch.start()
方法的具体详情如下:
包路径:org.apache.commons.lang3.time.StopWatch
类名称:StopWatch
方法名:start
[英]Start the stopwatch.
This method starts a new timing session, clearing any previous values.
[中]启动秒表。
此方法启动一个新的计时会话,清除所有以前的值。
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Provides a started stopwatch for convenience.
*
* @return StopWatch a stopwatch that's already been started.
*
* @since 3.5
*/
public static StopWatch createStarted() {
final StopWatch sw = new StopWatch();
sw.start();
return sw;
}
代码示例来源: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
boolean isclosed = dfs.isFileClosed(partPath);
StopWatch sw = new StopWatch();
sw.start();
while (!isclosed) {
if (sw.getTime() > asyncTimeout) {
sw.start();
long newLen = fs.getFileStatus(partPath).getLen();
while (newLen != validLength) {
代码示例来源:origin: apache/flink
boolean isclosed = dfs.isFileClosed(partPath);
StopWatch sw = new StopWatch();
sw.start();
while (!isclosed) {
if (sw.getTime() > asyncTimeout) {
sw.start();
long newLen = fs.getFileStatus(partPath).getLen();
while (newLen != bucketState.currentFileValidLength) {
代码示例来源:origin: apache/flink
sw.start();
代码示例来源: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: 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: 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: apache/hbase
get.setCacheBlocks(false);
get.setFilter(new FirstKeyOnlyFilter());
stopWatch.start();
table.get(get);
stopWatch.stop();
scan.setMaxResultSize(1L);
scan.setOneRowLimit();
stopWatch.start();
ResultScanner s = table.getScanner(scan);
s.next();
代码示例来源: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: 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/usergrid
timer.start();
final Set<Edge> ids = new HashSet<Edge>( limit );
timer.reset();
timer.start();
代码示例来源: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
timer.start();
timer.reset();
timer.start();
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testGetStartTime() {
final long beforeStopWatch = System.currentTimeMillis();
final StopWatch watch = new StopWatch();
try {
watch.getStartTime();
fail("Calling getStartTime on an unstarted StopWatch should throw an exception");
} catch (final IllegalStateException expected) {
// expected
}
watch.start();
try {
watch.getStartTime();
assertTrue(watch.getStartTime() >= beforeStopWatch);
} catch (final IllegalStateException ex) {
fail("Start time should be available: " + ex.getMessage());
}
watch.reset();
try {
watch.getStartTime();
fail("Calling getStartTime on a reset, but unstarted StopWatch should throw an exception");
} catch (final IllegalStateException expected) {
// expected
}
}
代码示例来源: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: 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
timer.start();
Set<Id> ids = new HashSet<Id>();
for (int i = 0; i < limit; i++) {
timer.reset();
timer.start();
for ( Id id : ids ) {
Entity entity = manager.load( id ).toBlocking().last();
代码示例来源:origin: org.apache.commons/commons-lang3
watch.start();
watch.start();
fail("Calling start on a started StopWatch should throw an exception. ");
} catch (final IllegalStateException ise) {
watch.start();
fail("Calling start on a stopped StopWatch should throw an exception as it needs to be reset. ");
} catch (final IllegalStateException ise) {
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testBooleanStates() {
final StopWatch watch = new StopWatch();
assertFalse(watch.isStarted());
assertFalse(watch.isSuspended());
assertTrue(watch.isStopped());
watch.start();
assertTrue(watch.isStarted());
assertFalse(watch.isSuspended());
assertFalse(watch.isStopped());
watch.suspend();
assertTrue(watch.isStarted());
assertTrue(watch.isSuspended());
assertFalse(watch.isStopped());
watch.stop();
assertFalse(watch.isStarted());
assertFalse(watch.isSuspended());
assertTrue(watch.isStopped());
}
内容来源于网络,如有侵权,请联系作者删除!