本文整理匯總了Java中org.springframework.util.StopWatch.getTotalTimeMillis方法的典型用法代碼示例。如果您正苦於以下問題:Java StopWatch.getTotalTimeMillis方法的具體用法?Java StopWatch.getTotalTimeMillis怎麽用?Java StopWatch.getTotalTimeMillis使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.util.StopWatch
的用法示例。
在下文中一共展示了StopWatch.getTotalTimeMillis方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: responseEnd
import org.springframework.util.StopWatch; //導入方法依賴的package包/類
@Override
public void responseEnd(StopWatch requestWatch, HttpServerResponse response) {
requestWatch.stop();
counterService.increment("responses.count.total");
int statusCode = response.getStatusCode();
long totalTimeMillis = requestWatch.getTotalTimeMillis();
gaugeService.submit("responses.totalTime.all", totalTimeMillis);
if (statusCode > 400) {
gaugeService.submit("responses.totalTime.error.all", totalTimeMillis);
counterService.increment("responses.count.error.total");
if (statusCode > 500) {
counterService.increment("responses.count.error.server");
gaugeService.submit("responses.totalTime.error.server", totalTimeMillis);
} else {
counterService.increment("responses.count.error.client");
gaugeService.submit("responses.totalTime.error.client", totalTimeMillis);
}
} else if (statusCode > 300) {
counterService.increment("responses.count.redirect");
gaugeService.submit("responses.totalTime.redirect", totalTimeMillis);
} else if (statusCode > 200) {
counterService.increment("responses.count.success");
gaugeService.submit("responses.totalTime.success", totalTimeMillis);
}
}
示例2: invoke
import org.springframework.util.StopWatch; //導入方法依賴的package包/類
@Around("@annotation(com.apssouza.monitoring.Monitored)")
public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable {
System.out.println("callend");
Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
if (this.enabled) {
StopWatch sw = new StopWatch(joinPoint.toShortString());
sw.start("invoke");
try {
return joinPoint.proceed();
} finally {
sw.stop();
synchronized (this) {
this.callCount++;
this.accumulatedCallTime += sw.getTotalTimeMillis();
}
publisher.publishEvent(new MonitoringInvokedEvent(
method.getName(),
this.accumulatedCallTime
));
}
} else {
return joinPoint.proceed();
}
}
示例3: invoke
import org.springframework.util.StopWatch; //導入方法依賴的package包/類
@Around("within(@org.springframework.stereotype.Repository *)")
public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable {
if (this.enabled) {
StopWatch sw = new StopWatch(joinPoint.toShortString());
sw.start("invoke");
try {
return joinPoint.proceed();
} finally {
sw.stop();
synchronized (this) {
this.callCount++;
this.accumulatedCallTime += sw.getTotalTimeMillis();
}
}
} else {
return joinPoint.proceed();
}
}
示例4: initDb
import org.springframework.util.StopWatch; //導入方法依賴的package包/類
protected void initDb() throws LiquibaseException {
StopWatch watch = new StopWatch();
watch.start();
super.afterPropertiesSet();
watch.stop();
logger.debug(STARTED_MESSAGE, watch.getTotalTimeMillis());
if (watch.getTotalTimeMillis() > SLOWNESS_THRESHOLD * 1000L) {
logger.warn(SLOWNESS_MESSAGE, SLOWNESS_THRESHOLD);
}
}
示例5: createTimerString
import org.springframework.util.StopWatch; //導入方法依賴的package包/類
private String createTimerString(StopWatch stopWatch) {
long millis = stopWatch.getTotalTimeMillis();
return format(" [%d ms]", millis);
}
示例6: stopTiming
import org.springframework.util.StopWatch; //導入方法依賴的package包/類
static long stopTiming(StopWatch stopWatch) {
if (stopWatch.isRunning()) {
stopWatch.stop();
}
return stopWatch.getTotalTimeMillis();
}
示例7: assertStopWatchTimeLimit
import org.springframework.util.StopWatch; //導入方法依賴的package包/類
private static void assertStopWatchTimeLimit(final StopWatch sw, final long maxTimeMillis) {
final long totalTimeMillis = sw.getTotalTimeMillis();
assertTrue("'" + sw.getLastTaskName() + "' took too long: expected less than<" + maxTimeMillis
+ "> ms, actual<" + totalTimeMillis + "> ms.", totalTimeMillis < maxTimeMillis);
}