|
48 | 48 | import java.util.concurrent.Executors; |
49 | 49 | import java.util.concurrent.Future; |
50 | 50 | import java.util.concurrent.TimeUnit; |
| 51 | +import java.util.concurrent.atomic.AtomicLong; |
51 | 52 | import java.util.concurrent.locks.ReentrantLock; |
52 | 53 |
|
53 | 54 | /** |
@@ -940,7 +941,7 @@ private static class StressTestTask implements Runnable { |
940 | 941 | private final ProgressTracker progressTracker; |
941 | 942 |
|
942 | 943 | /** The count of bytes used by the sub-process. */ |
943 | | - private long bytesUsed; |
| 944 | + private AtomicLong bytesUsed = new AtomicLong(); |
944 | 945 |
|
945 | 946 | /** |
946 | 947 | * Creates the task. |
@@ -1015,17 +1016,18 @@ private Integer runSubProcess() throws IOException { |
1015 | 1016 | final Process testingProcess = builder.start(); |
1016 | 1017 |
|
1017 | 1018 | // Use a custom data output to write the RNG. |
| 1019 | + long writeCount = 0; |
1018 | 1020 | try (RngDataOutput sink = RNGUtils.createDataOutput(rng, cmd.source64, |
1019 | 1021 | testingProcess.getOutputStream(), cmd.bufferSize, cmd.byteOrder)) { |
1020 | 1022 | for (;;) { |
1021 | 1023 | sink.write(rng); |
1022 | | - bytesUsed++; |
| 1024 | + writeCount++; |
1023 | 1025 | } |
1024 | 1026 | } catch (final IOException ignored) { |
1025 | 1027 | // Hopefully getting here when the analyzing software terminates. |
1026 | 1028 | } |
1027 | 1029 |
|
1028 | | - bytesUsed *= cmd.bufferSize; |
| 1030 | + bytesUsed.set(writeCount * cmd.bufferSize); |
1029 | 1031 |
|
1030 | 1032 | // Get the exit value. |
1031 | 1033 | // Wait for up to 60 seconds. |
@@ -1094,10 +1096,11 @@ private void printFooter(long millis, |
1094 | 1096 |
|
1095 | 1097 | appendDate(sb, "End").append(C).append(N); |
1096 | 1098 |
|
| 1099 | + final long bytes = bytesUsed.get(); |
1097 | 1100 | sb.append(C).append("Exit value: ").append(exitValue).append(N) |
1098 | | - .append(C).append("Bytes used: ").append(bytesUsed) |
1099 | | - .append(" >= 2^").append(log2(bytesUsed)) |
1100 | | - .append(" (").append(bytesToString(bytesUsed)).append(')').append(N) |
| 1101 | + .append(C).append("Bytes used: ").append(bytes) |
| 1102 | + .append(" >= 2^").append(log2(bytes)) |
| 1103 | + .append(" (").append(bytesToString(bytes)).append(')').append(N) |
1101 | 1104 | .append(C).append(N); |
1102 | 1105 |
|
1103 | 1106 | final double duration = millis * 1e-3 / 60; |
|
0 commit comments