-
-
Save talgol/14a5755db1ac83f4f6c04d71ad57c2e3 to your computer and use it in GitHub Desktop.
A program that makes many memory allocation - for measuring the ratio of local/remote memory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NUMABenchmarkService { | |
private static final long TIME_TO_RUN = 3600000 * 12; | |
private static final int NUM_OF_THREADS = 1; | |
private final ExecutorService executorService; | |
class MemoryTest implements Runnable { | |
@Override | |
public void run() { | |
long timeToStop = System.currentTimeMillis() + TIME_TO_RUN; | |
int sum = 0; | |
while(System.currentTimeMillis() < timeToStop) { | |
final byte[][] arrays = new byte[1_000_000][]; | |
for (int i = 0; i < arrays.length; i++) { | |
arrays[i] = new byte[1000]; | |
ThreadLocalRandom.current().nextBytes(arrays[i]); | |
} | |
for (long l = 0; l < 1_000_000_000L; l++) { | |
final byte[] array = arrays[ThreadLocalRandom.current().nextInt(arrays.length)]; | |
sum += array[ThreadLocalRandom.current().nextInt(array.length)]; | |
} | |
writeThreadMetrics(); | |
} | |
System.out.println(sum); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment