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

net.serenitybdd.core.time.Stopwatch Maven / Gradle / Ivy

package net.serenitybdd.core.time;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Stopwatch {

    private static final Logger LOGGER = LoggerFactory.getLogger(Stopwatch.class);

    long startTime = 0;

    public static Stopwatch started() {
        Stopwatch stopwatch = new Stopwatch();
        stopwatch.start();
        return stopwatch;
    }

    public void start() {
        startTime = System.currentTimeMillis();
    }

    public long stop() {
        long result = System.currentTimeMillis() - startTime;
        startTime = 0;
        return result;
    }

    public long lapTime() {
        return System.currentTimeMillis() - startTime;
    }

    public long stop(String message) {
        long result = stop();
        LOGGER.debug(message + " took {0} ms", +result);
        return result;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy