use of de.invesdwin.util.time.Instant in project invesdwin-context-persistence by subes.
the class TreeMapDBPerformanceTest method readGet.
private void readGet(final APersistentNavigableMap<FDate, FDate> table) throws InterruptedException {
final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck(Duration.ONE_SECOND);
final List<FDate> values = Lists.toList(newValues());
final Instant readsStart = new Instant();
for (int reads = 1; reads <= READS; reads++) {
FDate prevValue = null;
for (int i = 0; i < values.size(); i++) {
try {
final FDate value = table.get(values.get(i));
if (prevValue != null) {
Assertions.checkTrue(prevValue.isBefore(value));
}
prevValue = value;
} catch (final NoSuchElementException e) {
break;
}
}
if (loopCheck.check()) {
printProgress("Gets", readsStart, VALUES * reads, VALUES * READS);
}
}
printProgress("GetsFinished", readsStart, VALUES * READS, VALUES * READS);
}
use of de.invesdwin.util.time.Instant in project invesdwin-context-persistence by subes.
the class TreeMapDBPerformanceTest method testTreeMapDbPerformance.
@Test
public void testTreeMapDbPerformance() throws InterruptedException {
@SuppressWarnings("resource") final APersistentNavigableMap<FDate, FDate> table = new APersistentNavigableMap<FDate, FDate>("testTreeMapDbPerformance") {
@Override
public File getBaseDirectory() {
return ContextProperties.TEMP_DIRECTORY;
}
@Override
public ISerde<FDate> newKeySerde() {
return FDateSerde.GET;
}
@Override
public ISerde<FDate> newValueSerde() {
return FDateSerde.GET;
}
@Override
protected IPersistentNavigableMapFactory<FDate, FDate> newFactory() {
return new PersistentTreeMapDBFactory<>();
}
};
final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck(Duration.ONE_SECOND);
final Instant writesStart = new Instant();
int i = 0;
for (final FDate date : newValues()) {
table.put(date, date);
i++;
if (i % FLUSH_INTERVAL == 0) {
if (loopCheck.check()) {
printProgress("Writes", writesStart, i, VALUES);
}
}
}
printProgress("WritesFinished", writesStart, VALUES, VALUES);
readIterator(table);
readGet(table);
readGetLatest(table);
table.deleteTable();
}
use of de.invesdwin.util.time.Instant in project invesdwin-context-persistence by subes.
the class QuestDBPerformanceTest method readIterator.
private void readIterator(final CairoEngine engine) throws InterruptedException, SqlException {
final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck(Duration.ONE_SECOND);
final Instant readsStart = new Instant();
final SqlExecutionContextImpl ctx = new SqlExecutionContextImpl(engine, 1);
try (SqlCompiler compiler = new SqlCompiler(engine)) {
for (int reads = 1; reads <= READS; reads++) {
FDate prevValue = null;
int count = 0;
try (RecordCursorFactory factory = compiler.compile("abc ORDER BY key ASC", ctx).getRecordCursorFactory()) {
try (RecordCursor cursor = factory.getCursor(ctx)) {
final io.questdb.cairo.sql.Record record = cursor.getRecord();
while (cursor.hasNext()) {
final FDate value = new FDate(record.getLong(0));
if (prevValue != null) {
Assertions.checkTrue(prevValue.isBefore(value));
}
prevValue = value;
count++;
}
}
}
Assertions.checkEquals(count, VALUES);
if (loopCheck.check()) {
printProgress("Reads", readsStart, VALUES * reads, VALUES * READS);
}
}
}
printProgress("ReadsFinished", readsStart, VALUES * READS, VALUES * READS);
}
use of de.invesdwin.util.time.Instant in project invesdwin-context-persistence by subes.
the class MapDBPerformanceTest method testMapDbPerformance.
@Test
public void testMapDbPerformance() throws InterruptedException {
@SuppressWarnings("resource") final APersistentMap<FDate, FDate> table = new APersistentMap<FDate, FDate>("testMapDbPerformance") {
@Override
public File getBaseDirectory() {
return ContextProperties.TEMP_DIRECTORY;
}
@Override
public ISerde<FDate> newKeySerde() {
return FDateSerde.GET;
}
@Override
public ISerde<FDate> newValueSerde() {
return FDateSerde.GET;
}
@Override
protected IPersistentMapFactory<FDate, FDate> newFactory() {
return new PersistentMapDBFactory<>();
}
};
final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck(Duration.ONE_SECOND);
final Instant writesStart = new Instant();
int i = 0;
for (final FDate date : newValues()) {
table.put(date, date);
i++;
if (i % FLUSH_INTERVAL == 0) {
if (loopCheck.check()) {
printProgress("Writes", writesStart, i, VALUES);
}
}
}
printProgress("WritesFinished", writesStart, VALUES, VALUES);
readIterator(table);
readGet(table);
table.deleteTable();
}
use of de.invesdwin.util.time.Instant in project invesdwin-context-persistence by subes.
the class MapDBPerformanceTest method readIterator.
private void readIterator(final APersistentMap<FDate, FDate> table) throws InterruptedException {
final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck(Duration.ONE_SECOND);
final Instant readsStart = new Instant();
for (int reads = 1; reads <= READS; reads++) {
// FDate prevValue = null;
final Iterator<FDate> range = table.values().iterator();
int count = 0;
while (true) {
try {
final FDate value = range.next();
// if (prevValue != null) {
// Assertions.checkTrue(prevValue.isBefore(value));
// }
// prevValue = value;
count++;
} catch (final NoSuchElementException e) {
break;
}
}
Assertions.checkEquals(count, VALUES);
if (loopCheck.check()) {
printProgress("Reads", readsStart, VALUES * reads, VALUES * READS);
}
}
printProgress("ReadsFinished", readsStart, VALUES * READS, VALUES * READS);
}
Aggregations