本文整理了Java中org.springframework.util.StopWatch.shortSummary()
方法的一些代码示例,展示了StopWatch.shortSummary()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StopWatch.shortSummary()
方法的具体详情如下:
包路径:org.springframework.util.StopWatch
类名称:StopWatch
方法名:shortSummary
[英]Return a short description of the total running time.
[中]返回总运行时间的简短描述。
代码示例来源:origin: spring-projects/spring-framework
/**
* Return an informative string describing all tasks performed
* For custom reporting, call {@code getTaskInfo()} and use the task info directly.
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder(shortSummary());
if (this.keepTaskList) {
for (TaskInfo task : getTaskInfo()) {
sb.append("; [").append(task.getTaskName()).append("] took ").append(task.getTimeMillis());
long percent = Math.round((100.0 * task.getTimeSeconds()) / getTotalTimeSeconds());
sb.append(" = ").append(percent).append("%");
}
}
else {
sb.append("; no task info kept");
}
return sb.toString();
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Return a string with a table describing all tasks performed.
* For custom reporting, call getTaskInfo() and use the task info directly.
*/
public String prettyPrint() {
StringBuilder sb = new StringBuilder(shortSummary());
sb.append('\n');
if (!this.keepTaskList) {
sb.append("No task info kept");
}
else {
sb.append("-----------------------------------------\n");
sb.append("ms % Task name\n");
sb.append("-----------------------------------------\n");
NumberFormat nf = NumberFormat.getNumberInstance();
nf.setMinimumIntegerDigits(5);
nf.setGroupingUsed(false);
NumberFormat pf = NumberFormat.getPercentInstance();
pf.setMinimumIntegerDigits(3);
pf.setGroupingUsed(false);
for (TaskInfo task : getTaskInfo()) {
sb.append(nf.format(task.getTimeMillis())).append(" ");
sb.append(pf.format(task.getTimeSeconds() / getTotalTimeSeconds())).append(" ");
sb.append(task.getTaskName()).append("\n");
}
}
return sb.toString();
}
代码示例来源:origin: org.springframework/spring-core
/**
* Return an informative string describing all tasks performed
* For custom reporting, call {@code getTaskInfo()} and use the task info directly.
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder(shortSummary());
if (this.keepTaskList) {
for (TaskInfo task : getTaskInfo()) {
sb.append("; [").append(task.getTaskName()).append("] took ").append(task.getTimeMillis());
long percent = Math.round((100.0 * task.getTimeSeconds()) / getTotalTimeSeconds());
sb.append(" = ").append(percent).append("%");
}
}
else {
sb.append("; no task info kept");
}
return sb.toString();
}
代码示例来源:origin: org.springframework/spring-core
/**
* Return a string with a table describing all tasks performed.
* For custom reporting, call getTaskInfo() and use the task info directly.
*/
public String prettyPrint() {
StringBuilder sb = new StringBuilder(shortSummary());
sb.append('\n');
if (!this.keepTaskList) {
sb.append("No task info kept");
}
else {
sb.append("-----------------------------------------\n");
sb.append("ms % Task name\n");
sb.append("-----------------------------------------\n");
NumberFormat nf = NumberFormat.getNumberInstance();
nf.setMinimumIntegerDigits(5);
nf.setGroupingUsed(false);
NumberFormat pf = NumberFormat.getPercentInstance();
pf.setMinimumIntegerDigits(3);
pf.setGroupingUsed(false);
for (TaskInfo task : getTaskInfo()) {
sb.append(nf.format(task.getTimeMillis())).append(" ");
sb.append(pf.format(task.getTimeSeconds() / getTotalTimeSeconds())).append(" ");
sb.append(task.getTaskName()).append("\n");
}
}
return sb.toString();
}
代码示例来源:origin: spring-projects/spring-framework
@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
String name = createInvocationTraceName(invocation);
StopWatch stopWatch = new StopWatch(name);
stopWatch.start(name);
try {
return invocation.proceed();
}
finally {
stopWatch.stop();
writeToLog(logger, stopWatch.shortSummary());
}
}
代码示例来源:origin: spring-projects/spring-batch
private int doTest(String name, String test) throws Exception {
@SuppressWarnings("unchecked")
ItemStreamReader<String> reader = (ItemStreamReader<String>) applicationContext.getBean(name);
reader.open(new ExecutionContext());
StopWatch stopWatch = new StopWatch(test);
stopWatch.start();
int count = 0;
while (reader.read() != null) {
// do nothing
count++;
}
stopWatch.stop();
reader.close();
logger.info(stopWatch.shortSummary());
return count;
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Return an informative string describing all tasks performed
* For custom reporting, call <code>getTaskInfo()</code> and use the task info directly.
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder(shortSummary());
if (this.keepTaskList) {
for (TaskInfo task : getTaskInfo()) {
sb.append("; [").append(task.getTaskName()).append("] took ").append(task.getTimeMillis());
long percent = Math.round((100.0 * task.getTimeSeconds()) / getTotalTimeSeconds());
sb.append(" = ").append(percent).append("%");
}
} else {
sb.append("; no task info kept");
}
return sb.toString();
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Return a string with a table describing all tasks performed.
* For custom reporting, call getTaskInfo() and use the task info directly.
*/
public String prettyPrint() {
StringBuilder sb = new StringBuilder(shortSummary());
sb.append('\n');
if (!this.keepTaskList) {
sb.append("No task info kept");
} else {
sb.append("-----------------------------------------\n");
sb.append("ms % Task name\n");
sb.append("-----------------------------------------\n");
NumberFormat nf = NumberFormat.getNumberInstance();
nf.setMinimumIntegerDigits(5);
nf.setGroupingUsed(false);
NumberFormat pf = NumberFormat.getPercentInstance();
pf.setMinimumIntegerDigits(3);
pf.setGroupingUsed(false);
for (TaskInfo task : getTaskInfo()) {
sb.append(nf.format(task.getTimeMillis())).append(" ");
sb.append(pf.format(task.getTimeSeconds() / getTotalTimeSeconds())).append(" ");
sb.append(task.getTaskName()).append("\n");
}
}
return sb.toString();
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-core
/**
* Return a string with a table describing all tasks performed.
* For custom reporting, call getTaskInfo() and use the task info directly.
*/
public String prettyPrint() {
StringBuilder sb = new StringBuilder(shortSummary());
sb.append('\n');
if (!this.keepTaskList) {
sb.append("No task info kept");
}
else {
sb.append("-----------------------------------------\n");
sb.append("ms % Task name\n");
sb.append("-----------------------------------------\n");
NumberFormat nf = NumberFormat.getNumberInstance();
nf.setMinimumIntegerDigits(5);
nf.setGroupingUsed(false);
NumberFormat pf = NumberFormat.getPercentInstance();
pf.setMinimumIntegerDigits(3);
pf.setGroupingUsed(false);
for (TaskInfo task : getTaskInfo()) {
sb.append(nf.format(task.getTimeMillis())).append(" ");
sb.append(pf.format(task.getTimeSeconds() / getTotalTimeSeconds())).append(" ");
sb.append(task.getTaskName()).append("\n");
}
}
return sb.toString();
}
代码示例来源:origin: warszawajug/spring-labs
@Around("anyRepositoryMethodExecution()")
public Object monitor(ProceedingJoinPoint joinPoint) throws Throwable {
StopWatch stopWatch = new StopWatch(nameOf(joinPoint));
stopWatch.start();
try {
return joinPoint.proceed();
} finally {
stopWatch.stop();
log.info(stopWatch.shortSummary());
}
}
代码示例来源:origin: com.github.robert2411.platform.logging/executiontime-spring-aop
@Around("@annotation(com.github.robert2411.platform.logging.executiontime.api.LogExecutionTime)")
public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
StopWatch stopWatch = new StopWatch(joinPoint.getSignature().toString());
stopWatch.start();
Object proceed = joinPoint.proceed();
stopWatch.stop();
log.info(stopWatch.shortSummary());
return proceed;
}
}
代码示例来源:origin: warszawajug/spring-labs
@Around("anyRepositoryMethodExecution()")
public Object monitor(ProceedingJoinPoint joinPoint) throws Throwable {
StopWatch stopWatch = new StopWatch(nameOf(joinPoint));
stopWatch.start();
try {
// TODO #4 execute the advised method
return joinPoint.proceed();
} finally {
stopWatch.stop();
log.info(stopWatch.shortSummary());
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-core
/**
* Return an informative string describing all tasks performed
* For custom reporting, call {@code getTaskInfo()} and use the task info directly.
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder(shortSummary());
if (this.keepTaskList) {
for (TaskInfo task : getTaskInfo()) {
sb.append("; [").append(task.getTaskName()).append("] took ").append(task.getTimeMillis());
long percent = Math.round((100.0 * task.getTimeSeconds()) / getTotalTimeSeconds());
sb.append(" = ").append(percent).append("%");
}
}
else {
sb.append("; no task info kept");
}
return sb.toString();
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Return an informative string describing all tasks performed
* For custom reporting, call {@code getTaskInfo()} and use the task info directly.
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder(shortSummary());
if (this.keepTaskList) {
for (TaskInfo task : getTaskInfo()) {
sb.append("; [").append(task.getTaskName()).append("] took ").append(task.getTimeMillis());
long percent = Math.round((100.0 * task.getTimeSeconds()) / getTotalTimeSeconds());
sb.append(" = ").append(percent).append("%");
}
}
else {
sb.append("; no task info kept");
}
return sb.toString();
}
代码示例来源:origin: springframework/spring-aop
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
String name = createInvocationTraceName(invocation);
StopWatch stopWatch = new StopWatch(name);
stopWatch.start(name);
try {
return invocation.proceed();
}
finally {
stopWatch.stop();
logger.trace(stopWatch.shortSummary());
}
}
代码示例来源:origin: springframework/spring-core
/**
* Return an informative string describing all tasks performed
* For custom reporting, call getTaskInfo() and use the task info directly.
*/
public String toString() {
StringBuffer sb = new StringBuffer(shortSummary());
if (this.keepTaskList) {
TaskInfo[] tasks = getTaskInfo();
for (int i = 0; i < tasks.length; i++) {
if (i > 0) {
sb.append("; ");
}
sb.append("[" + tasks[i].getTaskName() + "] took " + tasks[i].getTimeMillis());
long percent = Math.round((100.0 * tasks[i].getTimeSeconds()) / getTotalTimeSeconds());
sb.append("=" + percent + "%");
}
}
else {
sb.append("Not keeping task info");
}
return sb.toString();
}
代码示例来源:origin: warszawajug/spring-labs
public Object monitor(ProceedingJoinPoint joinPoint) throws Throwable {
StopWatch stopWatch = new StopWatch(nameOf(joinPoint));
stopWatch.start();
try {
// TODO #4 execute the advised method
return null;
} finally {
stopWatch.stop();
log.info(stopWatch.shortSummary());
}
}
代码示例来源:origin: persado/stevia
public void maskExistingController(Method m) throws Throwable {
StopWatch watch = new StopWatch("Controller Mask");
try {
RunsWithController rw =
(m.getDeclaringClass().getAnnotation(RunsWithController.class) != null) ?
m.getDeclaringClass().getAnnotation(RunsWithController.class) :
m.getAnnotation(RunsWithController.class);
if (null != rw) {
watch.start("Controller masking");
Class<? extends WebController> requestedControllerClass = rw.value();
controllerMask(requestedControllerClass);
watch.stop();
} else {
throw new IllegalStateException("unable to find an entry for the annotation!");
}
} finally {
if (watch.isRunning()) {
watch.stop();
}
LOG.info(watch.shortSummary());
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-aop
@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
String name = createInvocationTraceName(invocation);
StopWatch stopWatch = new StopWatch(name);
stopWatch.start(name);
try {
return invocation.proceed();
}
finally {
stopWatch.stop();
writeToLog(logger, stopWatch.shortSummary());
}
}
代码示例来源:origin: apache/servicemix-bundles
@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
String name = createInvocationTraceName(invocation);
StopWatch stopWatch = new StopWatch(name);
stopWatch.start(name);
try {
return invocation.proceed();
}
finally {
stopWatch.stop();
writeToLog(logger, stopWatch.shortSummary());
}
}
内容来源于网络,如有侵权,请联系作者删除!