68 lines
2.1 KiB
Java
68 lines
2.1 KiB
Java
package it.cavallium.strangedb.tests.performance;
|
|
|
|
import it.cavallium.strangedb.java.objects.lists.EnhancedObjectStrangeDbList;
|
|
import it.cavallium.strangedb.java.objects.lists.ListQuery;
|
|
import it.cavallium.strangedb.java.objects.lists.ValuePointer;
|
|
import it.cavallium.strangedb.java.objects.lists.operations.ContainsIgnoreCase;
|
|
import it.cavallium.strangedb.tests.Performance;
|
|
import it.cavallium.strangedb.tests.query.*;
|
|
|
|
import java.io.IOException;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Random;
|
|
|
|
public class PerformanceListQuery implements PerformanceTest {
|
|
private final int items;
|
|
private Performance.PreloadedListContainer preloadedListContainer;
|
|
|
|
public PerformanceListQuery(int items) {
|
|
this.items = items;
|
|
}
|
|
|
|
@Override
|
|
public void setup() throws IOException {
|
|
Performance.regenDb();
|
|
preloadedListContainer = Performance.db.loadRoot(Performance.PreloadedListContainer::new);
|
|
}
|
|
|
|
@Override
|
|
public void perTestSetup() throws IOException {
|
|
preloadedListContainer.listOfMessages = new EnhancedObjectStrangeDbList<>(Performance.db);
|
|
|
|
Random random = new Random();
|
|
for (int i = 0; i < items; i++) {
|
|
EMessageContent content;
|
|
if (random.nextBoolean()) {
|
|
List<String> stringList = new ArrayList<>();
|
|
for (int j = 0; j < 10; j++) {
|
|
stringList.add("[entity]");
|
|
}
|
|
byte[] stringBytes = new byte[200];
|
|
random.nextBytes(stringBytes);
|
|
content = new EMessageText(Performance.db, new EFormattedText(Performance.db, new String(stringBytes, StandardCharsets.UTF_8) + (random.nextBoolean() ? "not found" : " text to find!"), stringList.toArray(new String[0])));
|
|
} else {
|
|
content = new EMessageOtherContent(Performance.db, "EMPTY ABCDEFG");
|
|
}
|
|
EMessage message = new EMessage(Performance.db, content);
|
|
preloadedListContainer.listOfMessages.add(message);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void test() throws IOException {
|
|
PerformanceListQueryTest.test(preloadedListContainer);
|
|
}
|
|
|
|
@Override
|
|
public void perTestEnd() throws IOException {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void end() throws IOException {
|
|
|
|
}
|
|
}
|