com.yammer.metrics.core.Timer.time()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(5.4k)|赞(0)|评价(0)|浏览(99)

本文整理了Java中com.yammer.metrics.core.Timer.time()方法的一些代码示例,展示了Timer.time()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Timer.time()方法的具体详情如下:
包路径:com.yammer.metrics.core.Timer
类名称:Timer
方法名:time

Timer.time介绍

[英]Returns a timing TimerContext, which measures an elapsed time in nanoseconds.
[中]返回计时TimerContext,它以纳秒为单位测量经过的时间。

代码示例

代码示例来源:origin: apache/usergrid

@Override
public Future submit( final Collection<Count> counts ) {
  return executor.submit( new Callable<Object>() {
    final TimerContext timer = addTimer.time();
    @Override
    public Object call() throws Exception {
      cassandraCounterStore.save( counts );
      timer.stop();
      return true;
    }
  } );
}

代码示例来源:origin: apache/usergrid

@Override
public Future submit( final Collection<Count> counts ) {
  return executor.submit( new Callable<Object>() {
    final TimerContext timer = addTimer.time();
    @Override
    public Object call() throws Exception {
      // TODO perhaps this could be pushed down further into CountProducer Impl?
      // - this would leave generic submitter class
      for ( Count c : counts ) {
        logger.info( "found count {}", c );
      }
      timer.stop();
      return true;
    }
  } );
}

代码示例来源:origin: apache/usergrid

public TestAPNsNotification( byte[] token, String payload) {
  super(token, payload, Calendar.getInstance().getTime());
  this.timer = processTimer.time();
}

代码示例来源:origin: apache/usergrid

/** Add a count object to this batcher */
public void add( Count count ) throws CounterProcessingUnavailableException {
  invocationCounter.inc();
  final TimerContext context = addTimer.time();
  if ( batchSize == 1 ) {
    getBatch().addSerial( count );
  }
  else {
    getBatch().add( count );
  }
  context.stop();
}

代码示例来源:origin: apache/usergrid

TimerContext timerCtx = timer.time();

代码示例来源:origin: hector-client/hector

@Override
public Object start(final String tagName) {
 final Timer timer = metricsRegistry.newTimer(new MetricName(clusterName, TIMER_TYPE, tagName),
   durationUnit, rateUnit);
 return timer.time();
}

代码示例来源:origin: sematext/ActionGenerator

/**
 * Starts sink timer.
 */
public void startSinkTimer() {
 sinkTimerContext = sinkTimer.time();
}

代码示例来源:origin: com.sematext.ag/ag-player

/** 
 * Start timer.
 */
public void startTimer() {
 context = timer.time();
}

代码示例来源:origin: rackerlabs/atom-hopper

private TimerContext startTimer(String name) {
  if (enableTimers) {
    final com.yammer.metrics.core.Timer timer = Metrics.newTimer( getClass(), name, TimeUnit.MILLISECONDS,
                                   TimeUnit.SECONDS );
    TimerContext context = timer.time();
    return context;
  } else {
    return null;
  }
}

代码示例来源:origin: neilbeveridge/zuul-netty

@Override
public void connectRequested(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
  this.connectStart = System.nanoTime();
  this.connectContext = connectTimer.time();
  super.connectRequested(ctx, e);
}

代码示例来源:origin: com.yammer.metrics/metrics-guice

@Override
  public Object invoke(MethodInvocation invocation) throws Throwable {
    final TimerContext ctx = timer.time();
    try {
      return invocation.proceed();
    } finally {
      ctx.stop();
    }
  }
}

代码示例来源:origin: com.yammer.metrics/metrics-spring

@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
  final Timer timer = timers.get(invocation.getMethod().getName());
  final TimerContext timerCtx = timer != null ? timer.time() : null;
  try {
    return invocation.proceed();
  } finally {
    if (timerCtx != null) {
      timerCtx.stop();
    }
  }
}

代码示例来源:origin: rackerlabs/atom-hopper

private TimerContext startTimer(String name) {
  if (enableTimers) {
    final com.yammer.metrics.core.Timer timer = Metrics.newTimer(getClass(), name, TimeUnit.MILLISECONDS, TimeUnit.SECONDS);
    TimerContext context = timer.time();
    return context;
  } else {
    return null;
  }
}

代码示例来源:origin: addthis/hydra

private static boolean executeAndTimeInsert(PreparedStatement preparedStatement) throws SQLException {
  TimerContext timerContext = insertTimer.time();
  try {
    return preparedStatement.execute();
  } catch (SQLException e) {
    errorCounter.inc();
    throw e;
  } finally {
    timerContext.stop();
  }
}

代码示例来源:origin: com.yammer.metrics/metrics-jersey

@Override
  public void dispatch(Object resource, HttpContext httpContext) {
    final TimerContext context = timer.time();
    try {
      underlying.dispatch(resource, httpContext);
    } finally {
      context.stop();
    }
  }
}

代码示例来源:origin: org.hectorclient/hector-core

@Override
public Object start(final String tagName) {
 final Timer timer = metricsRegistry.newTimer(new MetricName(clusterName, TIMER_TYPE, tagName),
   durationUnit, rateUnit);
 return timer.time();
}

代码示例来源:origin: 1000Memories/photon-core

public static BufferedImage crop(BufferedImage image, Rectangle bounds) throws Exception {
    TimerContext cropContext = cropTimer.time();
    BufferedImage result = AsyncScalr.crop(image, bounds.x, bounds.y, bounds.width, bounds.height).get();
    image.flush();
    cropContext.stop();
    return result;
  }
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-server

void awaitDiskSync()
{
  while (segment.lastSyncedOffset < position)
  {
    WaitQueue.Signal signal = segment.syncComplete.register(CommitLog.instance.metrics.waitingOnCommit.time());
    if (segment.lastSyncedOffset < position)
      signal.awaitUninterruptibly();
    else
      signal.cancel();
  }
}

代码示例来源:origin: com.yammer.metrics/metrics-httpclient

@Override
public HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context) throws HttpException, IOException {
  final TimerContext timerContext = timer(request).time();
  try {
    return super.execute(target, request, context);
  } finally {
    timerContext.stop();
  }
}

代码示例来源:origin: addthis/hydra

public void updateFileStats() {
  final TimerContext updateTimer = minion.fileStatsTimer.time();
  FileStats stats = new FileStats();
  stats.update(jobDir);
  try {
    LessFiles.write(new File(getConfigDir(), "job.stats"), LessBytes.toBytes(CodecJSON.encodeString(stats)), false);
  } catch (Exception e) {
    log.warn("", e);
  }
  fileCount = stats.count;
  fileBytes = stats.bytes;
  updateTimer.stop();
}

相关文章