use of cn.hutool.core.date.TimeInterval in project hutool by dromara.
the class ReflectUtilTest method getMethodBenchTest.
@Test
@Ignore
public void getMethodBenchTest() {
// 预热
getMethod(TestBenchClass.class, false, "getH");
final TimeInterval timer = DateUtil.timer();
timer.start();
for (int i = 0; i < 100000000; i++) {
ReflectUtil.getMethod(TestBenchClass.class, false, "getH");
}
Console.log(timer.interval());
timer.restart();
for (int i = 0; i < 100000000; i++) {
getMethod(TestBenchClass.class, false, "getH");
}
Console.log(timer.interval());
}
use of cn.hutool.core.date.TimeInterval in project hutool by dromara.
the class HttpRequestTest method asyncGetTest.
@Test
@Ignore
public void asyncGetTest() {
TimeInterval timer = DateUtil.timer();
HttpResponse body = HttpRequest.get(url).charset("GBK").executeAsync();
long interval = timer.interval();
timer.restart();
Console.log(body.body());
long interval2 = timer.interval();
Console.log("Async response spend {}ms, body spend {}ms", interval, interval2);
}
use of cn.hutool.core.date.TimeInterval in project springboot-templet-start by thedestiny.
the class AppPrintSqlPlugin method intercept.
// Executor -> ParameterHandler -> StatementHandler -> ResultSetHandler
// org.apache.ibatis.logging.stdout.StdOutImpl
/**
* 生成主键
*/
@Override
public Object intercept(Invocation invocation) throws Throwable {
log.info("invocation is {}", JSONObject.toJSONString(invocation));
Object[] args = invocation.getArgs();
MappedStatement statement = (MappedStatement) args[0];
Object parameter = args[1];
BoundSql boundSql = statement.getBoundSql(parameter);
Configuration configuration = statement.getConfiguration();
TimeInterval timer = DateUtil.timer();
try {
return invocation.proceed();
} catch (Exception e) {
} finally {
long cost = timer.intervalSecond();
log.info("cost time is {} and sql is \n{}", cost, getSql(configuration, boundSql));
}
// 获取到SQL 注意当前SQL是没有被设置参数过的SQL
return invocation.proceed();
}
Aggregations