de.dagere.kopeme.datacollection.TimeDataCollector Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kopeme-core Show documentation
Show all versions of kopeme-core Show documentation
KoPeMe performance testing core
package de.dagere.kopeme.datacollection;
/**
* Saves time in nanoseconds.
*
* @author dagere
*
*/
public final class TimeDataCollector extends DataCollector {
private long start;
private long stop;
private long summarizedValue = 0;
/**
* Initializes the TimeDataCollector.
*/
public TimeDataCollector() {
start = 0;
stop = 0;
}
@Override
public int getPriority() {
return Integer.MAX_VALUE;
}
@Override
public void startCollection() {
System.gc();
start = System.nanoTime();
}
@Override
public void stopCollection() {
stop = System.nanoTime();
}
@Override
public long getValue() {
return summarizedValue != 0 ? summarizedValue : (stop - start);
}
@Override
public void startOrRestartCollection() {
summarizedValue += (stop - start);
System.out.println("Measured: " + summarizedValue);
startCollection();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy