@Override public void onCompleted() { timer.stop(); latch.countDown(); }
@Override public void onCompleted() { timer.stop(); latch.countDown(); }
@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; } }
@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); }
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"); }
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; }
@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); }
@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); }
timer.stop(); logger.info( "Total time to write {} entries {}ms", limit, timer.getTime() ); timer.reset();
@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()); }
timer.stop(); logger.info( "Total time to write {} entries {} ms", writeLimit, timer.getTime() ); timer.reset();
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 } ); }
rs.next(); stopWatch.stop(); this.readWriteLatency.add(stopWatch.getTime()); sink.publishReadTiming(serverName, region, column, stopWatch.getTime());
entityIndex.search( indexEdge, searchTypes, "select * where uuid = '"+uuid+"'", 100, 0, false ); timer.stop();
final StopWatch watch = new StopWatch(); try { watch.stop(); fail("Calling stop on an unstarted StopWatch should throw an exception. "); } catch (final IllegalStateException ise) { watch.stop(); fail("Calling stop on an unstarted StopWatch should throw an exception. "); } catch (final IllegalStateException ise) { watch.stop();
@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()); }
entityIndex.search( indexEdge, searchTypes, "select * where testfield = 'test' order by ordinal", 100, 0, false ); timer.stop();
protected void fileStreamComplete(String filename, boolean success) { String duration = com.willwinder.universalgcodesender.Utils. formattedMillis(this.getSendDuration()); this.dispatchConsoleMessage(MessageType.INFO,"\n**** Finished sending file in "+duration+" ****\n\n"); this.streamStopWatch.stop(); this.isStreaming = false; dispatchStreamComplete(filename, success); }