|
@@ -147,12 +147,13 @@ public class UnlockedController extends AbstractFXMLViewController {
|
|
|
|
|
|
private static final double BYTES_TO_MEGABYTES_FACTOR = 1.0 / IO_SAMPLING_INTERVAL / 1024.0 / 1024.0;
|
|
|
private static final double SMOOTHING_FACTOR = 0.3;
|
|
|
+ private static final long EFFECTIVELY_ZERO = 100000; // 100kb
|
|
|
private final CryptorIOSampling sampler;
|
|
|
private final Series<Number, Number> decryptedBytes;
|
|
|
private final Series<Number, Number> encryptedBytes;
|
|
|
private int step = 0;
|
|
|
- private double oldDecBytes = 0;
|
|
|
- private double oldEncBytes = 0;
|
|
|
+ private long oldDecBytes = 0;
|
|
|
+ private long oldEncBytes = 0;
|
|
|
|
|
|
public IoSamplingAnimationHandler(CryptorIOSampling sampler, Series<Number, Number> decryptedBytes, Series<Number, Number> encryptedBytes) {
|
|
|
this.sampler = sampler;
|
|
@@ -164,19 +165,19 @@ public class UnlockedController extends AbstractFXMLViewController {
|
|
|
public void handle(ActionEvent event) {
|
|
|
step++;
|
|
|
|
|
|
- final double decBytes = sampler.pollDecryptedBytes(true);
|
|
|
+ final long decBytes = sampler.pollDecryptedBytes(true);
|
|
|
final double smoothedDecBytes = oldDecBytes + SMOOTHING_FACTOR * (decBytes - oldDecBytes);
|
|
|
final double smoothedDecMb = smoothedDecBytes * BYTES_TO_MEGABYTES_FACTOR;
|
|
|
- oldDecBytes = smoothedDecBytes;
|
|
|
+ oldDecBytes = smoothedDecBytes > EFFECTIVELY_ZERO ? (long) smoothedDecBytes : 0l;
|
|
|
decryptedBytes.getData().add(new Data<Number, Number>(step, smoothedDecMb));
|
|
|
if (decryptedBytes.getData().size() > IO_SAMPLING_STEPS) {
|
|
|
decryptedBytes.getData().remove(0);
|
|
|
}
|
|
|
|
|
|
- final double encBytes = sampler.pollEncryptedBytes(true);
|
|
|
+ final long encBytes = sampler.pollEncryptedBytes(true);
|
|
|
final double smoothedEncBytes = oldEncBytes + SMOOTHING_FACTOR * (encBytes - oldEncBytes);
|
|
|
final double smoothedEncMb = smoothedEncBytes * BYTES_TO_MEGABYTES_FACTOR;
|
|
|
- oldEncBytes = smoothedEncBytes;
|
|
|
+ oldEncBytes = smoothedEncBytes > EFFECTIVELY_ZERO ? (long) smoothedEncBytes : 0l;
|
|
|
encryptedBytes.getData().add(new Data<Number, Number>(step, smoothedEncMb));
|
|
|
if (encryptedBytes.getData().size() > IO_SAMPLING_STEPS) {
|
|
|
encryptedBytes.getData().remove(0);
|