✨ logs
This commit is contained in:
parent
5007636aaf
commit
21e1bc3b56
|
@ -25,13 +25,13 @@ public class ExecutionTimeInterceptor {
|
||||||
// 开始:虚拟机运行时对象
|
// 开始:虚拟机运行时对象
|
||||||
Runtime startRuntime = Runtime.getRuntime();
|
Runtime startRuntime = Runtime.getRuntime();
|
||||||
// 开始:总内存
|
// 开始:总内存
|
||||||
long totalMemory = startRuntime.totalMemory();
|
long startTotalMemory = startRuntime.totalMemory();
|
||||||
// 开始:最大内存
|
// 开始:最大内存
|
||||||
long maxMemory = startRuntime.maxMemory();
|
long startMaxMemory = startRuntime.maxMemory();
|
||||||
// 开始:空闲内存
|
// 开始:空闲内存
|
||||||
long startFreeMemory = startRuntime.freeMemory();
|
long startFreeMemory = startRuntime.freeMemory();
|
||||||
// 开始:使用内存
|
// 开始:使用内存
|
||||||
long startUsedMemory = totalMemory - startFreeMemory;
|
long startUsedMemory = startTotalMemory - startFreeMemory;
|
||||||
|
|
||||||
Object result = callable.call();
|
Object result = callable.call();
|
||||||
|
|
||||||
|
@ -39,10 +39,14 @@ public class ExecutionTimeInterceptor {
|
||||||
long endTime = System.currentTimeMillis();
|
long endTime = System.currentTimeMillis();
|
||||||
// 结束:虚拟机运行时对象
|
// 结束:虚拟机运行时对象
|
||||||
Runtime endRuntime = Runtime.getRuntime();
|
Runtime endRuntime = Runtime.getRuntime();
|
||||||
|
// 结束:总内存
|
||||||
|
long endTotalMemory = endRuntime.totalMemory();
|
||||||
|
// 结束:最大内存
|
||||||
|
long endMaxMemory = endRuntime.maxMemory();
|
||||||
// 结束:空闲内存
|
// 结束:空闲内存
|
||||||
long endFreeMemory = endRuntime.freeMemory();
|
long endFreeMemory = endRuntime.freeMemory();
|
||||||
// 结束:使用内存
|
// 结束:使用内存
|
||||||
long endUsedMemory = totalMemory - endFreeMemory;
|
long endUsedMemory = endTotalMemory - endFreeMemory;
|
||||||
|
|
||||||
Class<?> declaringClass = method.getDeclaringClass();
|
Class<?> declaringClass = method.getDeclaringClass();
|
||||||
String declaringClassName = declaringClass.getName();
|
String declaringClassName = declaringClass.getName();
|
||||||
|
@ -55,9 +59,9 @@ public class ExecutionTimeInterceptor {
|
||||||
parameterTypeNameBuilder.append(parameterType.getTypeName());
|
parameterTypeNameBuilder.append(parameterType.getTypeName());
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("执行耗时: {} ms,开始内存:{},结束内存: {},使用内存: {}", (endTime - startTime),
|
logger.info("执行耗时: {} ms, maxMemory: {}, totalMemory: ↑ {}, freeMemory: ↑ {}", (endTime - startTime),
|
||||||
DataSize.ofBytes(startUsedMemory).toStringLongUnit(),
|
DataSize.ofBytes(startMaxMemory).toStringLongUnit(),
|
||||||
DataSize.ofBytes(endUsedMemory).toStringLongUnit(),
|
DataSize.ofBytes(endTotalMemory - startTotalMemory).toStringLongUnit(),
|
||||||
DataSize.ofBytes(endFreeMemory - startFreeMemory).toStringLongUnit());
|
DataSize.ofBytes(endFreeMemory - startFreeMemory).toStringLongUnit());
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Reference in New Issue