Guava之StopWatch

    private static void process(String orderNo) throws InterruptedException {

        LOGGER.info("start process the order [{}]", orderNo);
        Stopwatch stopwatch = Stopwatch.createStarted();
        TimeUnit.MILLISECONDS.sleep(100);

        LOGGER.info("The orderNo [{}] process successful and elapsed [{}] min.", orderNo, stopwatch.stop().elapsed(TimeUnit.MINUTES));

        /**
         * stopwatch.reset() 继续使用
         */
    }

查看 StopWatch 源码 底层有用到ServiceLoader

你可能感兴趣的:(Guava之StopWatch)