Second try on reading data from memory.
This commit is contained in:
parent
a7f0bc4822
commit
8c530c3477
|
@ -3,8 +3,6 @@ package biz.nellemann.memstress;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import picocli.CommandLine;
|
import picocli.CommandLine;
|
||||||
|
|
||||||
import java.util.Scanner;
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
@CommandLine.Command(name = "memstress", mixinStandardHelpOptions = true, versionProvider = VersionProvider.class, description = "Memory performance measurement tool.")
|
@CommandLine.Command(name = "memstress", mixinStandardHelpOptions = true, versionProvider = VersionProvider.class, description = "Memory performance measurement tool.")
|
||||||
|
@ -29,12 +27,6 @@ public class Application implements Callable<Integer> {
|
||||||
MyDatabase database = new MyDatabase(maxTables, maxRowsPerTable, maxDataPerRow);
|
MyDatabase database = new MyDatabase(maxTables, maxRowsPerTable, maxDataPerRow);
|
||||||
database.write("testDb");
|
database.write("testDb");
|
||||||
database.read("testDb");
|
database.read("testDb");
|
||||||
|
|
||||||
Scanner scanner = new Scanner(System.in);
|
|
||||||
System.out.println("Press ENTER to stop");
|
|
||||||
String s= scanner.nextLine();
|
|
||||||
scanner.close();
|
|
||||||
|
|
||||||
database.destroy("testDb");
|
database.destroy("testDb");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class MyDatabase {
|
||||||
for (int t = 1; t <= maxTables; t++) {
|
for (int t = 1; t <= maxTables; t++) {
|
||||||
|
|
||||||
String tableName = String.format("table_%d", t);
|
String tableName = String.format("table_%d", t);
|
||||||
log.info("Creating table \"{}\"", tableName);
|
log.debug("Creating table \"{}\"", tableName);
|
||||||
|
|
||||||
Table table = database.createTable(tableName);
|
Table table = database.createTable(tableName);
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ public class MyDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
Instant instant2 = Instant.now();
|
Instant instant2 = Instant.now();
|
||||||
log.info("Done writing {} to \"{}\" in {}", bytesWritten, dbName, Duration.between(instant1, instant2));
|
log.info("Done writing {}b to \"{}\" in {}", bytesWritten, dbName, Duration.between(instant1, instant2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,13 +87,17 @@ public class MyDatabase {
|
||||||
table.getRows().forEach((idx, row) -> {
|
table.getRows().forEach((idx, row) -> {
|
||||||
HashMap<String, ByteBuffer> values = row.getColumnValuesMap();
|
HashMap<String, ByteBuffer> values = row.getColumnValuesMap();
|
||||||
values.forEach((str, byteBuffer) -> {
|
values.forEach((str, byteBuffer) -> {
|
||||||
byte[] array = byteBuffer.array();
|
byteBuffer.rewind();
|
||||||
bytesRead.addAndGet(array.length);
|
while (byteBuffer.hasRemaining()) {
|
||||||
|
byte[] tmp = new byte[BYTE_SIZE_1MB];
|
||||||
|
byteBuffer.get(tmp);
|
||||||
|
bytesRead.addAndGet(tmp.length);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Instant instant2 = Instant.now();
|
Instant instant2 = Instant.now();
|
||||||
log.info("Done reading {} from \"{}\" in {}", bytesRead.get(), dbName, Duration.between(instant1, instant2));
|
log.info("Done reading {}b from \"{}\" in {}", bytesRead.get(), dbName, Duration.between(instant1, instant2));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue