
com.graphaware.common.stopwatch.Event Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common Show documentation
Show all versions of common Show documentation
General-Purpose Library of Neo4j-Related Code
package com.graphaware.common.stopwatch;
import java.util.ArrayList;
import java.util.List;
public class Event {
private Long start;
private List periods = new ArrayList<>();
private boolean isStopped = false;
public Event() {
start = System.currentTimeMillis();
}
public void stop() {
periods.add(new Period(getLastPeriodTime(), System.currentTimeMillis()));
}
public Long getStartTime() {
return start;
}
public Long duration() {
return getLastPeriodTime() - start;
}
public void addPeriod() {
periods.add(new Period(getLastPeriodTime(), System.currentTimeMillis()));
}
public List getPeriods() {
return periods;
}
private Long getLastPeriodTime() {
return periods.size() == 0 ? start : periods.get(periods.size()-1).endTime();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy