/*
* 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());
}
}
輸出結果