Search in sources :

Example 11 with TimeInterval

use of cn.hutool.core.date.TimeInterval in project hutool by looly.

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 12 with TimeInterval

use of cn.hutool.core.date.TimeInterval in project hutool by looly.

the class IdUtilTest method benchTest.

/**
 * UUID的性能测试
 */
@Test
@Ignore
public void benchTest() {
    TimeInterval timer = DateUtil.timer();
    for (int i = 0; i < 1000000; i++) {
        IdUtil.simpleUUID();
    }
    Console.log(timer.interval());
    timer.restart();
    for (int i = 0; i < 1000000; i++) {
        // noinspection ResultOfMethodCallIgnored
        UUID.randomUUID().toString().replace("-", "");
    }
    Console.log(timer.interval());
}
Also used : TimeInterval(cn.hutool.core.date.TimeInterval) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 13 with TimeInterval

use of cn.hutool.core.date.TimeInterval in project hutool by looly.

the class StrBuilderTest method benchTest.

/**
 * StrBuilder的性能测试
 */
@Test
@Ignore
public void benchTest() {
    TimeInterval timer = DateUtil.timer();
    StrBuilder builder = StrBuilder.create();
    for (int i = 0; i < 1000000; i++) {
        builder.append("test");
        builder.reset();
    }
    Console.log(timer.interval());
    timer.restart();
    StringBuilder b2 = new StringBuilder();
    for (int i = 0; i < 1000000; i++) {
        b2.append("test");
        b2 = new StringBuilder();
    }
    Console.log(timer.interval());
}
Also used : TimeInterval(cn.hutool.core.date.TimeInterval) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 14 with TimeInterval

use of cn.hutool.core.date.TimeInterval in project hutool by looly.

the class DateUtilTest method timerTest.

@Test
public void timerTest() {
    TimeInterval timer = DateUtil.timer();
    // ---------------------------------
    // -------这是执行过程
    // ---------------------------------
    // 花费毫秒数
    timer.interval();
    // 返回花费时间,并重置开始时间
    timer.intervalRestart();
    // 花费分钟数
    timer.intervalMinute();
}
Also used : TimeInterval(cn.hutool.core.date.TimeInterval) Test(org.junit.Test)

Example 15 with TimeInterval

use of cn.hutool.core.date.TimeInterval in project hutool by looly.

the class HttpRequestTest method syncGetTest.

@Test
@Ignore
public void syncGetTest() {
    TimeInterval timer = DateUtil.timer();
    HttpResponse body = HttpRequest.get(url).charset("GBK").execute();
    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) HttpResponse(cn.hutool.http.HttpResponse) Ignore(org.junit.Ignore) Test(org.junit.Test)

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