1 Star 0 Fork 342

大哥 / source-code-hunter

forked from doocs / source-code-hunter 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Spring-StopWatch.md 1.51 KB
一键复制 编辑 原始数据 按行查看 历史
ylb 提交于 2020-09-03 17:04 . fix: 更新文档格式

Spring StopWatch

属性

  • taskList: 任务信息列表
  • keepTaskList: 是否保留任务信息列表
  • startTimeMillis: 任务开始的时间
  • currentTaskName: 任务名称
  • lastTaskInfo: 任务信息
  • taskCount: 任务数量
  • totalTimeMillis: 总共花费的时间

方法

  • org.springframework.util.StopWatch.start(java.lang.String)
    public void start(String taskName) throws IllegalStateException {
        if (this.currentTaskName != null) {
            throw new IllegalStateException("Can't start StopWatch: it's already running");
        }
        this.currentTaskName = taskName;
        this.startTimeMillis = System.currentTimeMillis();
    }
  • org.springframework.util.StopWatch.stop
    public void stop() throws IllegalStateException {
        if (this.currentTaskName == null) {
            throw new IllegalStateException("Can't stop StopWatch: it's not running");
        }
        // 消费的时间
        long lastTime = System.currentTimeMillis() - this.startTimeMillis;
        this.totalTimeMillis += lastTime;
        // 任务信息初始化
        this.lastTaskInfo = new TaskInfo(this.currentTaskName, lastTime);
        if (this.keepTaskList) {
            this.taskList.add(this.lastTaskInfo);
        }
        ++this.taskCount;
        this.currentTaskName = null;
    }
1
https://gitee.com/dagechen/source-code-hunter.git
git@gitee.com:dagechen/source-code-hunter.git
dagechen
source-code-hunter
source-code-hunter
main

搜索帮助