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

com.eg.agent.android.stats.TicToc Maven / Gradle / Ivy

There is a newer version: 2.1.3
Show newest version
package com.eg.agent.android.stats;

public class TicToc {
    private long endTime;
    private long startTime;
    private State state;

    private enum State {
        STOPPED,
        STARTED
    }

    public void tic() {
        this.state = State.STARTED;
        this.startTime = System.currentTimeMillis();
    }

    public long toc() {
        this.endTime = System.currentTimeMillis();
        if (this.state != State.STARTED) {
            return -1;
        }
        this.state = State.STOPPED;
        return this.endTime - this.startTime;
    }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy