Average times and multiple test iterations.
This commit is contained in:
parent
8c530c3477
commit
e1d3395fa3
35
README.md
35
README.md
|
@ -3,39 +3,12 @@
|
|||
|
||||
## Examples
|
||||
|
||||
Test with 8GB memory:
|
||||
```shell
|
||||
java -Xms128g -Xmx128g -XX:+UseLargePages -XX:+AlwaysPreTouch \
|
||||
-XX:-UseParallelGC -XX:MaxGCPauseMillis=500 -Xgcthreads3 \
|
||||
-jar memstress-0.0.1-all.jar -t 96
|
||||
java -Xms10g -Xmx10g -XX:+AlwaysPreTouch -jar memstress-0.0.1-all.jar -t 8
|
||||
```
|
||||
|
||||
|
||||
Test with 100GB memory:
|
||||
```shell
|
||||
java -Xms144g -Xmx144g -XX:+UseLargePages -XX:+AlwaysPreTouch \
|
||||
-XX:-UseParallelGC -XX:MaxGCPauseMillis=500 -Xgcthreads3 \
|
||||
-jar memstress-0.0.1-all.jar -t 128
|
||||
```
|
||||
|
||||
```shell
|
||||
java -Xms160g -Xmx160g -XX:+UseLargePages -XX:+AlwaysPreTouch \
|
||||
-XX:-UseParallelGC -XX:MaxGCPauseMillis=500 -Xgcthreads3 \
|
||||
-jar memstress-0.0.1-all.jar -t 144
|
||||
```
|
||||
|
||||
```shell
|
||||
java -Xms192g -Xmx192g -XX:+UseLargePages -XX:+AlwaysPreTouch \
|
||||
-XX:-UseParallelGC -XX:MaxGCPauseMillis=500 -Xgcthreads3 \
|
||||
-jar memstress-0.0.1-all.jar -t 160
|
||||
```
|
||||
|
||||
```shell
|
||||
java -Xms240g -Xmx240g -XX:+UseLargePages -XX:+AlwaysPreTouch \
|
||||
-XX:-UseParallelGC -XX:MaxGCPauseMillis=500 -Xgcthreads3 \
|
||||
-jar memstress-0.0.1-all.jar -t 192
|
||||
```
|
||||
|
||||
```shell
|
||||
java -Xms256g -Xmx256g -XX:+UseLargePages -XX:+AlwaysPreTouch \
|
||||
-XX:-UseParallelGC -XX:MaxGCPauseMillis=500 -Xgcthreads3 \
|
||||
-jar memstress-0.0.1-all.jar -t 240
|
||||
java -Xms128g -Xmx128g -XX:+AlwaysPreTouch -jar memstress-0.0.1-all.jar -t 100
|
||||
```
|
||||
|
|
|
@ -3,6 +3,8 @@ package biz.nellemann.memstress;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import picocli.CommandLine;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
@CommandLine.Command(name = "memstress", mixinStandardHelpOptions = true, versionProvider = VersionProvider.class, description = "Memory performance measurement tool.")
|
||||
|
@ -20,14 +22,25 @@ public class Application implements Callable<Integer> {
|
|||
@CommandLine.Option(names = { "-d", "--data" }, paramLabel = "NUM", description = "Create this much data (MB) pr. row [default: ${DEFAULT-VALUE}]")
|
||||
int maxDataPerRow = 100;
|
||||
|
||||
@CommandLine.Option(names = { "-i", "--iterations" }, paramLabel = "NUM", description = "Iterate test his many times [default: ${DEFAULT-VALUE}]")
|
||||
int iterations = 3;
|
||||
|
||||
@Override
|
||||
public Integer call() throws Exception {
|
||||
|
||||
MyDatabase database = new MyDatabase(maxTables, maxRowsPerTable, maxDataPerRow);
|
||||
database.write("testDb");
|
||||
database.read("testDb");
|
||||
database.destroy("testDb");
|
||||
long writeTimeMillis = 0;
|
||||
long readTimeMillis = 0;
|
||||
|
||||
for(int i = 1; i <= iterations; i++) {
|
||||
log.info("Starting test {} of {}", i, iterations);
|
||||
MemDatabase database = new MemDatabase(maxTables, maxRowsPerTable, maxDataPerRow);
|
||||
writeTimeMillis += database.write("testDb");
|
||||
readTimeMillis += database.read("testDb");
|
||||
database.destroy("testDb");
|
||||
}
|
||||
|
||||
log.info("Average writing time: {}", Duration.ofMillis(writeTimeMillis / iterations));
|
||||
log.info("Average reading time: {}", Duration.ofMillis(readTimeMillis / iterations));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -14,9 +14,9 @@ import java.util.Arrays;
|
|||
import java.util.HashMap;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
public class MyDatabase {
|
||||
public class MemDatabase {
|
||||
|
||||
final Logger log = LoggerFactory.getLogger(MyDatabase.class);
|
||||
final Logger log = LoggerFactory.getLogger(MemDatabase.class);
|
||||
|
||||
private final int BYTE_SIZE_1MB = 1_000_000;
|
||||
private final int BYTE_SIZE_1GB = 1_000_000_000;
|
||||
|
@ -35,7 +35,7 @@ public class MyDatabase {
|
|||
private char[] baseCar;
|
||||
private byte[] byteBase;
|
||||
|
||||
public MyDatabase(int tables, int rows, int size) {
|
||||
public MemDatabase(int tables, int rows, int size) {
|
||||
this.maxTables = tables;
|
||||
this.maxRowsPerTable = rows;
|
||||
this.maxDataPerRow = size;
|
||||
|
@ -48,7 +48,7 @@ public class MyDatabase {
|
|||
}
|
||||
|
||||
|
||||
public void write(String dbName) {
|
||||
public long write(String dbName) {
|
||||
Instant instant1 = Instant.now();
|
||||
Database database = databaseManager.createDatabase(dbName);
|
||||
|
||||
|
@ -74,11 +74,14 @@ public class MyDatabase {
|
|||
}
|
||||
|
||||
Instant instant2 = Instant.now();
|
||||
log.info("Done writing {}b to \"{}\" in {}", bytesWritten, dbName, Duration.between(instant1, instant2));
|
||||
Duration duration = Duration.between(instant1, instant2);
|
||||
log.info("Done writing {} bytes -> \"{}\" in {}", bytesWritten, dbName, duration);
|
||||
|
||||
return duration.toMillis();
|
||||
}
|
||||
|
||||
|
||||
public void read(String dbName) {
|
||||
public long read(String dbName) {
|
||||
Instant instant1 = Instant.now();
|
||||
Database database = databaseManager.getDatabase(dbName);
|
||||
|
||||
|
@ -97,8 +100,10 @@ public class MyDatabase {
|
|||
});
|
||||
}
|
||||
Instant instant2 = Instant.now();
|
||||
log.info("Done reading {}b from \"{}\" in {}", bytesRead.get(), dbName, Duration.between(instant1, instant2));
|
||||
Duration duration = Duration.between(instant1, instant2);
|
||||
log.info("Done reading {} bytes <- \"{}\" in {}", bytesRead.get(), dbName, duration);
|
||||
|
||||
return duration.toMillis();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in a new issue