Search in sources :

Example 16 with TimeInterval

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());
}
Also used : TimeInterval(cn.hutool.core.date.TimeInterval) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 17 with TimeInterval

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);
}
Also used : TimeInterval(cn.hutool.core.date.TimeInterval) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 18 with TimeInterval

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();
}
Also used : Configuration(org.apache.ibatis.session.Configuration) TimeInterval(cn.hutool.core.date.TimeInterval) BoundSql(org.apache.ibatis.mapping.BoundSql) JSONObject(com.alibaba.fastjson.JSONObject) MetaObject(org.apache.ibatis.reflection.MetaObject) MappedStatement(org.apache.ibatis.mapping.MappedStatement)

Aggregations

TimeInterval (cn.hutool.core.date.TimeInterval)18 Test (org.junit.Test)14 Ignore (org.junit.Ignore)12 HttpResponse (cn.hutool.http.HttpResponse)2 DateTime (cn.hutool.core.date.DateTime)1 Month (cn.hutool.core.date.Month)1 Quarter (cn.hutool.core.date.Quarter)1 JSONObject (com.alibaba.fastjson.JSONObject)1 ExceptionNoticeResponse (com.hccake.ballcat.autoconfigure.web.exception.domain.ExceptionNoticeResponse)1 Date (java.util.Date)1 BoundSql (org.apache.ibatis.mapping.BoundSql)1 MappedStatement (org.apache.ibatis.mapping.MappedStatement)1 MetaObject (org.apache.ibatis.reflection.MetaObject)1 Configuration (org.apache.ibatis.session.Configuration)1