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());
}
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());
}
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());
}
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();
}
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);
}
Aggregations