Development changes. #1

Merged
nellemann merged 6 commits from dev into main 2023-06-29 18:42:01 +00:00
2 changed files with 13 additions and 8 deletions
Showing only changes of commit 0f5ed50e86 - Show all commits

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