Flush executor
This commit is contained in:
parent
debe1f70bb
commit
b34af24e33
@ -24,7 +24,7 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class Performance {
|
||||
private static boolean FAST_TESTS;
|
||||
private static int DIVISOR;
|
||||
|
||||
private static Path rootDirectory;
|
||||
private static Path dbDataFile;
|
||||
@ -32,6 +32,21 @@ public class Performance {
|
||||
private static Path dbReferencesFile;
|
||||
private static DatabaseJava db;
|
||||
private static boolean tempDirectory;
|
||||
private static final int BASE_WIDTH = 35;
|
||||
private static final int SPACE_WIDTH = BASE_WIDTH + 35;
|
||||
private static String spaces = "";
|
||||
private static String bars = "";
|
||||
private static boolean doFillTests;
|
||||
private static boolean doLoadTests;
|
||||
private static boolean doQueryTests;
|
||||
private static boolean doInstantiationTests;
|
||||
|
||||
static {
|
||||
for (int i = 0; i < SPACE_WIDTH; i++) {
|
||||
spaces += " ";
|
||||
bars += "-";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
@ -40,13 +55,27 @@ public class Performance {
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public static void main(String[] args) throws IOException, InterruptedException {
|
||||
FAST_TESTS = args.length > 0 && args[0].equalsIgnoreCase("true");
|
||||
DIVISOR = args.length > 0 ? Integer.parseInt(args[0]) : 1;
|
||||
if (args.length >= 2) {
|
||||
rootDirectory = Paths.get(args[1]);
|
||||
try {
|
||||
doQueryTests =
|
||||
args[1].contains("query");
|
||||
doFillTests =
|
||||
args[1].contains("fill");
|
||||
doLoadTests =
|
||||
args[1].contains("load");
|
||||
doInstantiationTests =
|
||||
args[1].contains("new");
|
||||
if (args[1].contains("all")) {
|
||||
doQueryTests = true;
|
||||
doFillTests = true;
|
||||
doLoadTests = true;
|
||||
doInstantiationTests = true;
|
||||
}
|
||||
}
|
||||
if (args.length >= 3) {
|
||||
rootDirectory = Paths.get(args[2]);
|
||||
if (Files.notExists(rootDirectory)) {
|
||||
Files.createDirectory(rootDirectory);
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
tempDirectory = false;
|
||||
} else {
|
||||
@ -55,17 +84,22 @@ public class Performance {
|
||||
}
|
||||
generateDb();
|
||||
System.out.println("Performance test started.");
|
||||
System.out.println("-------------------------------------------------------+-----------------------------------------------------------------");
|
||||
System.out.println("Test name Total Time | Time at 1 Time at 10 Time at 100 Time at 1K Time at 10K");
|
||||
System.out.println("-------------------------------------------------------+-----------------------------------------------------------------");
|
||||
System.out.println(bars + "---------------+-----------------------------------------------------------------");
|
||||
System.out.println("Test name" + spaces.substring(0, spaces.length() - 5) + "Total Time | Time at 1 Time at 10 Time at 100 Time at 1K Time at 10K");
|
||||
System.out.println(bars + "---------------+-----------------------------------------------------------------");
|
||||
if (doInstantiationTests) {
|
||||
testS("DatabaseCore creation", 300, Performance::deleteDb, Performance::generateDb, () -> {});
|
||||
testS("DatabaseCore root creation", 300, Performance::regenDb, () -> db.loadRoot(PreloadedListContainer::new), () -> {});
|
||||
}
|
||||
final VariableWrapper<PreloadedListContainer> preloadedListContainer = new VariableWrapper<>(null);
|
||||
final VariableWrapper<SimpleEnhancedObject> simpleEnhancedObjectContainer = new VariableWrapper<>(null);
|
||||
testS("ObjectStrangeDbList<Int> creation", 3000, () -> {
|
||||
if (doInstantiationTests) {
|
||||
testS("ObjectStrangeDbList<Int> creation", 1000, () -> {
|
||||
regenDb();
|
||||
preloadedListContainer.var = db.loadRoot(PreloadedListContainer::new);
|
||||
}, () -> preloadedListContainer.var.list = new ObjectStrangeDbList<>(db), () -> {});
|
||||
}
|
||||
if (doFillTests) {
|
||||
testS("ObjectStrangeDbList<Int>: Filling with 1000 items", 100, () -> {
|
||||
regenDb();
|
||||
preloadedListContainer.var = db.loadRoot(PreloadedListContainer::new);
|
||||
@ -109,6 +143,8 @@ public class Performance {
|
||||
preloadedListContainer.var.list.add(1000);
|
||||
}
|
||||
}, () -> {});
|
||||
}
|
||||
if (doLoadTests) {
|
||||
testS("ObjectStrangeDbList<Int>: Loading 1000 items", 100, () -> {
|
||||
regenDb();
|
||||
preloadedListContainer.var = db.loadRoot(PreloadedListContainer::new);
|
||||
@ -183,6 +219,8 @@ public class Performance {
|
||||
}, () -> {
|
||||
preloadedListContainer.var.list.size();
|
||||
}, () -> {});
|
||||
}
|
||||
if (doQueryTests) {
|
||||
for (int items = 1000; items <= 100000; items *= 10) {
|
||||
final int itemsF = items;
|
||||
testS("ListQuery: query with " + items + " items", 100 / (items / 1000), () -> {
|
||||
@ -214,7 +252,8 @@ public class Performance {
|
||||
ArrayList<EMessage> results = preloadedListContainer.var.listOfMessages.query(query).asList();
|
||||
}, () -> {});
|
||||
}
|
||||
System.out.println("-------------------------------------------------------+-----------------------------------------------------------------");
|
||||
}
|
||||
System.out.println(bars + "---------------+-----------------------------------------------------------------");
|
||||
System.out.println("Performance test finished.");
|
||||
deleteDb();
|
||||
if (tempDirectory) {
|
||||
@ -225,21 +264,19 @@ public class Performance {
|
||||
private static void NtestS(String description, int times, RunnableWithIO beforeAction, RunnableWithIO action, RunnableWithIO afterAction) throws IOException, InterruptedException {
|
||||
}
|
||||
|
||||
|
||||
private static void testS(String description, int times, RunnableWithIO beforeAction, RunnableWithIO action, RunnableWithIO afterAction) throws IOException, InterruptedException {
|
||||
if (FAST_TESTS) {
|
||||
if (times >= 5) {
|
||||
times /= 5;
|
||||
} else if (times >= 2) {
|
||||
times /= 2;
|
||||
}
|
||||
|
||||
if (times >= 5 * DIVISOR) {
|
||||
times /= 5 * DIVISOR;
|
||||
} else if (times >= 2 * DIVISOR) {
|
||||
times /= 2 * DIVISOR;
|
||||
}
|
||||
description = description + " time is";
|
||||
int spacesCount = 40 - description.length();
|
||||
int spacesCount = SPACE_WIDTH - description.length();
|
||||
int cutAt = 0;
|
||||
if (spacesCount < 0) {
|
||||
spacesCount = 40 - (description.length() - 40);
|
||||
cutAt = 40;
|
||||
spacesCount = SPACE_WIDTH - (description.length() - SPACE_WIDTH);
|
||||
cutAt = SPACE_WIDTH;
|
||||
}
|
||||
StringBuilder spaces = new StringBuilder();
|
||||
for (int i = 0; i < spacesCount; i++) {
|
||||
|
@ -1 +0,0 @@
|
||||
Subproject commit b425e4c12901dd277f944bcf1b0b0f245d8d23b5
|
1
strangedb-core
Symbolic link
1
strangedb-core
Symbolic link
@ -0,0 +1 @@
|
||||
G:/Progetti/Java/Progetti_IntelliJ_Idea/StrangeDb Core
|
Loading…
Reference in New Issue
Block a user