Package com.google.common.base

Examples of com.google.common.base.Stopwatch.elapsedTime()


            break;
          }

          TimeUnit.NANOSECONDS.sleep(sleepNano);

          if (stopwatch.elapsedTime(unit) > timeout) {
            break;
          }
        }
      }
View Full Code Here


    while (!result.needProcess()) {
      if (timeoutNano <= 0) {
        break;
      }

      long elapsedNano = stopwatch.elapsedTime(TimeUnit.NANOSECONDS);
      if (elapsedNano + sleepNano >= timeoutNano) {
        break;
      }
      TimeUnit.NANOSECONDS.sleep(sleepNano);
      result = tryDequeue(timeoutNano - elapsedNano, TimeUnit.NANOSECONDS);
View Full Code Here

    private void doAWrite() throws IOException {
      Stopwatch sw = new Stopwatch().start();
      stm.write(toWrite);
      stm.hflush();
      long micros = sw.elapsedTime(TimeUnit.MICROSECONDS);
      quantiles.insert(micros);
    }
  }

View Full Code Here

                    ? new SuccessfulHealthCheckResult(endPoint.getId(), sw.stop().elapsedTime(TimeUnit.NANOSECONDS))
                    : new FailedHealthCheckResult(endPoint.getId(), sw.stop().elapsedTime(TimeUnit.NANOSECONDS));
        } catch (Exception e) {
            return new FailedHealthCheckResult(endPoint.getId(), sw.stop().elapsedTime(TimeUnit.NANOSECONDS), e);
        } finally {
            _healthCheckTime.update(sw.elapsedTime(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS);
        }
    }

    @VisibleForTesting
    final class HealthCheck implements Runnable {
View Full Code Here

        AsyncSocketMessageSender messageSender = new AsyncSocketMessageSender(5000, 1000, "localhost");
        Stopwatch stopwatch = new Stopwatch();
        stopwatch.start();
        messageSender.sendMessages();
        stopwatch.stop();
        System.out.println("Done sending messages in " + stopwatch.elapsedTime(TimeUnit.SECONDS));
    }

}
View Full Code Here

            public Long call() throws Exception {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.start();
                serverSocket.startServer();
                stopwatch.stop();
                return stopwatch.elapsedTime(TimeUnit.SECONDS);
            }
        });
        System.out.println("Starting the AsyncSocketServer Test");
        new Thread(asyncFutureTask).start();
        Thread.sleep(1000);
View Full Code Here

            public Long call() throws Exception {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.start();
                serverSocket.startServer();
                stopwatch.stop();
                return stopwatch.elapsedTime(TimeUnit.SECONDS);
            }
        });

        new Thread(plainFutureTask).start();
        Thread.sleep(1000);
View Full Code Here

      throw new ExecutionError(localError);
    }
    finally
    {
      if (i == 0)
        this.globalStatsCounter.recordLoadException(localStopwatch.elapsedTime(TimeUnit.NANOSECONDS));
    }
    if (localMap1 == null)
    {
      this.globalStatsCounter.recordLoadException(localStopwatch.elapsedTime(TimeUnit.NANOSECONDS));
      throw new CacheLoader.InvalidCacheLoadException(paramCacheLoader + " returned null map from loadAll");
View Full Code Here

      if (i == 0)
        this.globalStatsCounter.recordLoadException(localStopwatch.elapsedTime(TimeUnit.NANOSECONDS));
    }
    if (localMap1 == null)
    {
      this.globalStatsCounter.recordLoadException(localStopwatch.elapsedTime(TimeUnit.NANOSECONDS));
      throw new CacheLoader.InvalidCacheLoadException(paramCacheLoader + " returned null map from loadAll");
    }
    localStopwatch.stop();
    int j = 0;
    Iterator localIterator = localMap1.entrySet().iterator();
View Full Code Here

      else
        put(localObject2, localObject3);
    }
    if (j != 0)
    {
      this.globalStatsCounter.recordLoadException(localStopwatch.elapsedTime(TimeUnit.NANOSECONDS));
      throw new CacheLoader.InvalidCacheLoadException(paramCacheLoader + " returned null keys or values from loadAll");
    }
    this.globalStatsCounter.recordLoadSuccess(localStopwatch.elapsedTime(TimeUnit.NANOSECONDS));
    return localMap1;
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.