diff --git a/README.md b/README.md index e69de29..b881675 100644 --- a/README.md +++ b/README.md @@ -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 +``` diff --git a/src/main/java/biz/nellemann/memstress/MyDatabase.java b/src/main/java/biz/nellemann/memstress/MyDatabase.java index 174dcff..6d494c4 100644 --- a/src/main/java/biz/nellemann/memstress/MyDatabase.java +++ b/src/main/java/biz/nellemann/memstress/MyDatabase.java @@ -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); }