亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Spring中的StopWatch記錄操作時(shí)間代碼實(shí)例

 更新時(shí)間:2023年11月06日 09:18:22   作者:LOOPY_Y  
這篇文章主要介紹了Spring中的StopWatch記錄操作時(shí)間代碼實(shí)例,spring-framework提供的一個(gè)StopWatch類可以做類似任務(wù)執(zhí)行時(shí)間控制,也就是封裝了一個(gè)對(duì)開(kāi)始時(shí)間,結(jié)束時(shí)間記錄操作的Java類,需要的朋友可以參考下

StopWatch記錄操作時(shí)間

說(shuō)明

spring-framework提供的一個(gè)StopWatch類可以做類似任務(wù)執(zhí)行時(shí)間控制,也就是封裝了一個(gè)對(duì)開(kāi)始時(shí)間,結(jié)束時(shí)間記錄操作的Java類。

示例

start開(kāi)始記錄,stop停止記錄,然后通過(guò)StopWatch的prettyPrint方法,可直觀的輸出代碼執(zhí)行耗時(shí),以及執(zhí)行時(shí)間百分比。

public class TestStopWatch {
    public static void main(String[] args) throws InterruptedException {
        StopWatch sw = new StopWatch();
        sw.start("doSomething1");
        Thread.sleep(200);
        sw.stop();
        sw.start("doSomething2");
        Thread.sleep(200);
        sw.stop();
        sw.start("doSomething3");
        Thread.sleep(200);
        sw.stop();
        System.out.println(sw.prettyPrint());
    }
}

控制臺(tái)打印結(jié)果如下

StopWatch '': running time = 613210100 ns
---------------------------------------------
ns         %     Task name
---------------------------------------------
201980400  033%  doSomething1
201809600  033%  doSomething2
209420100  034%  doSomething3
Process finished with exit code 0

到此這篇關(guān)于Spring中的StopWatch記錄操作時(shí)間代碼實(shí)例的文章就介紹到這了,更多相關(guān)StopWatch記錄操作時(shí)間內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論