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.LoggerFactory;
|
||||
import picocli.CommandLine;
|
||||
|
||||
import java.util.Scanner;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
@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);
|
||||
database.write("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");
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -56,7 +56,7 @@ public class MyDatabase {
|
|||
for (int t = 1; t <= maxTables; t++) {
|
||||
|
||||
String tableName = String.format("table_%d", t);
|
||||
log.info("Creating table \"{}\"", tableName);
|
||||
log.debug("Creating table \"{}\"", tableName);
|
||||
|
||||
Table table = database.createTable(tableName);
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class MyDatabase {
|
|||
}
|
||||
|
||||
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) -> {
|
||||
HashMap<String, ByteBuffer> values = row.getColumnValuesMap();
|
||||
values.forEach((str, byteBuffer) -> {
|
||||
byte[] array = byteBuffer.array();
|
||||
bytesRead.addAndGet(array.length);
|
||||
byteBuffer.rewind();
|
||||
while (byteBuffer.hasRemaining()) {
|
||||
byte[] tmp = new byte[BYTE_SIZE_1MB];
|
||||
byteBuffer.get(tmp);
|
||||
bytesRead.addAndGet(tmp.length);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
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