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

com.redhat.lightblue.migrator.facade.Timer Maven / Gradle / Ivy

There is a newer version: 2.56.1
Show newest version
package com.redhat.lightblue.migrator.facade;

import java.util.Date;

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

/**
 * A helper class to measure method execution times.
 *
 * @author mpatercz
 *
 */
public class Timer {

    private static final Logger log = LoggerFactory.getLogger(Timer.class);

    public final String method;

    public final Date start;

    public Timer(String method) {
        super();
        this.method = method;
        this.start = new Date();
    }

    public long complete() {
        Date end = new Date();
        long callTookMS = end.getTime()-start.getTime();

        if (log.isDebugEnabled()) {
            log.debug(method+" call took "+ callTookMS + "ms");
        }

        return callTookMS;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy