spring 工具 StopWatch 調試性能問題

/*
 *  Inc.
 * Copyright (c) 2000-2019 All Rights Reserved.
 */
package com.aspire.zenglx.project.util;

import org.springframework.util.StopWatch;

/**
 * @author zengliangxi
 * @version $id:StopWatchUtil.java, v  2019/11/21 16:48:24, zengliangxi Exp $
 */
public class StopWatchUtil {

    public static void main(String[] args) {
    save();

    }


    public static void save() {
        StopWatch sw = new StopWatch("記錄方法save");
        sw.start("save片段1");
        int j=0;
        for(int i=0; i<10000000;i++) {
            j = j+i;
        }
        sw.stop();

        sw.start("save 代碼片段2");

        int m=0;
        for(int i=0; i<100000000;i++) {
            m = m+i;
        }
        sw.stop();

        System.out.println(sw.prettyPrint());

    }
}
 

輸出結果

發佈了22 篇原創文章 · 獲贊 4 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章