Java Code Examples for com.google.common.base.Stopwatch#toString()

The following examples show how to use com.google.common.base.Stopwatch#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TimingHandler.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@Nonnull
@Override
public Response handle(@Nonnull final Context context) throws Exception {
  Stopwatch watch = Stopwatch.createStarted();

  try {
    if (meteringHandler != null) {
      context.insertHandler(meteringHandler);
    }
    return context.proceed();
  }
  finally {
    String elapsed = watch.toString();
    context.getAttributes().set(ELAPSED_KEY, elapsed);
    log.trace("Timing: {}", elapsed);
  }
}
 
Example 2
Source File: N4jscCompiler.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
private void printCompileResults(Stopwatch elapsedTime) {
	long trsnp = callback.getTranspilationsCount();
	long deltd = callback.getDeletionsCount();
	long errs = callback.getErrorsCount();
	long wrns = callback.getWarningsCount();
	String durationStr = elapsedTime.toString();
	String msg = String.format(
			"Compile results - Transpiled: %d, Deleted: %d, Errors: %d, Warnings: %d, Duration: %s",
			trsnp, deltd, errs, wrns, durationStr);
	N4jscConsole.println(msg);
}
 
Example 3
Source File: N4jscCompiler.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
private void printCleanResults(Stopwatch elapsedTime) {
	long deltd = callback.getDeletionsCount();
	String durationStr = elapsedTime.toString();
	String msg = String.format("Clean results - Deleted: %d, Duration: %s", deltd, durationStr);
	N4jscConsole.println(msg);
}
 
Example 4
Source File: KPIDataResult.java    From metasfresh-webui-api-legacy with GNU General Public License v3.0 4 votes vote down vote up
public Builder setTook(final Stopwatch took)
{
	this.took = took.toString();
	return this;
}
 
Example 5
Source File: StatsInfo.java    From dropwizard-guicey with MIT License 3 votes vote down vote up
/**
 * Value is reported in best suited units (e.g. milliseconds, seconds, minutes etc).
 *
 * @param name statistic name
 * @return human readable (formatted) timer value or 0 (if stat value is not available)
 * @throws IllegalStateException if provided stat is not time stat
 */
public String humanTime(final Stat name) {
    name.requiresTimer();
    Preconditions.checkState(name.isTimer(), "Stat %s is not timer stat", name);
    final Stopwatch stopwatch = tracker.getTimers().get(name);
    return stopwatch == null ? "0" : stopwatch.toString();
}