README examples for running

This commit is contained in:
Mark Nellemann 2023-06-28 07:29:44 +02:00
parent e6db0b6f90
commit 0f5ed50e86
2 changed files with 13 additions and 8 deletions

View File

@ -0,0 +1,9 @@
# Memory Performance Test
## Examples
```shell
java -Xms128g -Xmx128g -XX:+UseLargePages -XX:+AlwaysPreTouch \
-XX:-UseParallelGC -XX:MaxGCPauseMillis=500 -Xgcthreads3 \
-jar memstress-0.0.1-all.jar -t 128
```

View File

@ -10,6 +10,7 @@ import java.nio.ByteBuffer;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Random;
@ -44,9 +45,7 @@ public class MyDatabase {
for (int i = 0; i < 128; i++) {
baseCar[i] = 'A';
}
for (int i = 0; i < byteBase.length; i++) {
byteBase[i] = 0;
}
Arrays.fill(byteBase, (byte) 0);
}
@ -79,16 +78,13 @@ public class MyDatabase {
String randomString() {
baseCar[(idx++) % 128]++;
String s = new String(baseCar);
return s;
return new String(baseCar);
}
ByteBuffer randomBytes() {
byteBase[(idx2++) % byteBase.length]++;
byte[] bytes = new byte[byteBase.length];
for (int i = 0; i < bytes.length; i++) {
bytes[i] = byteBase[i];
}
System.arraycopy(byteBase, 0, bytes, 0, bytes.length);
return ByteBuffer.wrap(bytes);
}