FastTime a faster alternative to System.currentTimeMillis
FastTime is 100 times faster (according to my primitive benchmark) than System.currentTimeMillis. It is less accurate.
This commit is contained in:
@@ -31,6 +31,7 @@ import org.lucares.pdb.datastore.WriteException;
|
||||
import org.lucares.pdb.datastore.internal.DataStore;
|
||||
import org.lucares.pdb.datastore.internal.PartitionDiskStore;
|
||||
import org.lucares.pdb.datastore.lang.SyntaxException;
|
||||
import org.lucares.utils.FastTime;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -94,7 +95,7 @@ public class PerformanceDb implements AutoCloseable {
|
||||
long insertionsSinceLastSync = 0;
|
||||
|
||||
try {
|
||||
long lastSync = System.currentTimeMillis();
|
||||
long lastSync = FastTime.currentTimeMillis();
|
||||
long nextSync = lastSync + timeBetweenSyncs.toMillis();
|
||||
|
||||
while (true) {
|
||||
@@ -116,15 +117,15 @@ public class PerformanceDb implements AutoCloseable {
|
||||
count++;
|
||||
insertionsSinceLastSync++;
|
||||
|
||||
if (nextSync <= System.currentTimeMillis()) {
|
||||
final long end = System.currentTimeMillis();
|
||||
if (nextSync <= FastTime.currentTimeMillis()) {
|
||||
final long end = FastTime.currentTimeMillis();
|
||||
final long duration = end - lastSync;
|
||||
final long entriesPerSecond = (long) (insertionsSinceLastSync / (duration / 1000.0));
|
||||
|
||||
METRICS_LOGGER.debug(String.format(Locale.US, "inserting %,11d/s ; total: %,d; last: %s",
|
||||
entriesPerSecond, count, entry));
|
||||
|
||||
lastSync = System.currentTimeMillis();
|
||||
lastSync = FastTime.currentTimeMillis();
|
||||
nextSync = lastSync + timeBetweenSyncs.toMillis();
|
||||
insertionsSinceLastSync = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user