Created
December 10, 2018 02:44
-
-
Save iamitshri/073e83ea85eb01143eae890961bf68e9 to your computer and use it in GitHub Desktop.
Using stopwatch from package org.apache.commons.lang3.time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.amit; | |
import org.apache.commons.lang3.time.StopWatch; | |
import lombok.extern.slf4j.Slf4j; | |
/** | |
* Hello world! | |
* | |
*/ | |
@Slf4j | |
public class App { | |
public static void main(String[] args) throws InterruptedException { | |
log.debug("Hello World!"); | |
StopWatch stopwatch = new StopWatch(); | |
stopwatch.start(); | |
Thread.sleep(1000l); | |
stopwatch.split(); | |
final long splitTime1 = stopwatch.getSplitTime(); | |
log.debug("time spent {}, split time:{}", stopwatch.toSplitString(), stopwatch.toSplitString()); | |
Thread.sleep(1000l); | |
stopwatch.split(); | |
log.debug("split time {}: Time since last split: {}", stopwatch.toSplitString(), | |
(stopwatch.getSplitTime() - splitTime1)); | |
Thread.sleep(1000l); | |
stopwatch.stop(); | |
log.debug("Total time spent {}", stopwatch.getTime()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
log4j2.properties