This commit is contained in:
Looly 2019-09-16 19:05:24 +08:00
parent 0fbede424e
commit 5026ee4dbe
2 changed files with 58 additions and 52 deletions

View File

@ -41,23 +41,36 @@ import cn.hutool.core.util.StrUtil;
*/
public class StopWatch {
/** 秒表唯一标识,用于多个秒表对象的区分 */
/**
* 秒表唯一标识用于多个秒表对象的区分
*/
private final String id;
private List<TaskInfo> taskList;
/** 任务名称 */
/**
* 任务名称
*/
private String currentTaskName;
/** 开始时间 */
/**
* 开始时间
*/
private long startTimeNanos;
/** 最后一次任务对象 */
/**
* 最后一次任务对象
*/
private TaskInfo lastTaskInfo;
/** 总任务数 */
/**
* 总任务数
*/
private int taskCount;
/** 总运行时间 */
/**
* 总运行时间
*/
private long totalTimeNanos;
// ------------------------------------------------------------------------------------------- Constructor start
/**
* 构造不启动任何任务
*/
@ -77,7 +90,7 @@ public class StopWatch {
/**
* 构造不启动任何任务
*
* @param id 用于标识秒表的唯一ID
* @param id 用于标识秒表的唯一ID
* @param keepTaskList 是否在停止后保留任务{@code false} 表示停止运行后不保留任务
*/
public StopWatch(String id, boolean keepTaskList) {
@ -283,12 +296,9 @@ public class StopWatch {
}
/**
* Get a short description of the total running time.
*/
/**
* 获取任务
* 获取任务信息
*
* @return
* @return 任务信息
*/
public String shortSummary() {
return StrUtil.format("StopWatch '{}': running time = {} ns", this.id, this.totalTimeNanos);
@ -344,7 +354,6 @@ public class StopWatch {
* 存放任务名称和花费时间对象
*
* @author Looly
*
*/
public static final class TaskInfo {

View File

@ -156,7 +156,7 @@ public class SettingLoader {
/**
* 赋值分隔符用于分隔键值对
*
* @param regex 正则
* @param assignFlag 正则
* @since 4.6.5
*/
public void setAssignFlag(char assignFlag) {
@ -174,8 +174,6 @@ public class SettingLoader {
try {
writer = FileUtil.getPrintWriter(absolutePath, charset, false);
store(writer);
} catch (IOException e) {
throw new IORuntimeException(e, "Store Setting to [{}] error!", absolutePath);
} finally {
IoUtil.close(writer);
}
@ -185,9 +183,8 @@ public class SettingLoader {
* 存储到Writer
*
* @param writer Writer
* @throws IOException IO异常
*/
synchronized private void store(PrintWriter writer) throws IOException {
synchronized private void store(PrintWriter writer) {
for (Entry<String, LinkedHashMap<String, String>> groupEntry : this.groupedMap.entrySet()) {
writer.println(StrUtil.format("{}{}{}", CharUtil.BRACKET_START, groupEntry.getKey(), CharUtil.BRACKET_END));
for (Entry<String, String> entry : groupEntry.getValue().entrySet()) {