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

cucumber.runtime.StopWatch Maven / Gradle / Ivy

There is a newer version: 1.2.6
Show newest version
package cucumber.runtime;

public interface StopWatch {
    void start();

    /**
     * @return nanoseconds since start
     */
    long stop();

    StopWatch SYSTEM = new StopWatch() {
        private final ThreadLocal start = new ThreadLocal();

        @Override
        public void start() {
            start.set(System.nanoTime());
        }

        @Override
        public long stop() {
            Long duration = System.nanoTime() - start.get();
            start.set(null);
            return duration;
        }
    };

    public static class Stub implements StopWatch {
        private final long duration;

        public Stub(long duration) {
            this.duration = duration;
        }

        @Override
        public void start() {
        }

        @Override
        public long stop() {
            return duration;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy