| 接口 | 说明 |
|---|---|
| Cost |
计算耗时
|
| 类 | 说明 |
|---|---|
| CostUtil |
计算耗时工具,支持秒,毫秒,纳秒
包括:
1.计算耗时,返回耗时结果
Cost cost = CostUtil.startMillisecondCost();
TimeUnit.MILLISECONDS.sleep(1000);
long millisecond = cost.stop();
2.计算耗时,自定义任务名称,输出耗时结果
Cost cost = CostUtil.startMillisecondCost("millisecondCostTest");
TimeUnit.MILLISECONDS.sleep(1000);
cost.stopAndPrint();
// millisecondCostTest cost: 1000 ms
3.计算耗时,返回精确计时,带3小数的结果,使用ROUND_DOWN 舍弃超过3位的小数部分
Cost cost = CostUtil.startMillisecondCost();
TimeUnit.NANOSECONDS.sleep(1000_500_000);
cost.stopAccurate();
// 1001.238
|
| MillisecondCost |
计算耗时,单位毫秒
|
| NanosecondCost |
计算耗时,单位纳秒
|
| SecondCost |
计算秒耗时,单位 秒
|
Copyright © 2021. All rights reserved.