All Downloads are FREE. Search and download functionalities are using the official Maven repository.

top.doudou.core.util.CostTime Maven / Gradle / Ivy

There is a newer version: 1.3.2
Show newest version
package top.doudou.core.util;

/**
 * @Description 耗时统计定义类
 * @Author 傻男人 <[email protected]>
 * @Date 2021-02-02 10:32
 * @Version V1.0
 */
public class CostTime implements AutoCloseable {
    private long start;

    public CostTime() {
        this.start = System.currentTimeMillis();
    }

    @Override
    public void close() {
        System.out.println("----->  该方法共耗时: " + (System.currentTimeMillis() - start) + "毫秒");
    }

    public static void cost(Runnable run) throws Exception {
        try (CostTime cost = new CostTime()){
            run.run();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy