mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-22 15:56:17 -04:00
Round kB/s as well
This commit is contained in:
parent
b261cb73ba
commit
1d5f2e8023
1 changed files with 8 additions and 7 deletions
|
@ -675,22 +675,23 @@ class Peer {
|
||||||
this._statusText = statusText;
|
this._statusText = statusText;
|
||||||
}
|
}
|
||||||
|
|
||||||
_calculateSpeedKbPerSecond() {
|
_getSpeedKbPerSecond() {
|
||||||
const timeDifferenceSeconds = (this._byteLogs[this._byteLogs.length - 1].time - this._byteLogs[0].time) / 1000;
|
const timeDifferenceSeconds = (this._byteLogs[this._byteLogs.length - 1].time - this._byteLogs[0].time) / 1000;
|
||||||
const bytesDifferenceKB = (this._byteLogs[this._byteLogs.length - 1].bytesReceived - this._byteLogs[0].bytesReceived) / 1000;
|
const bytesDifferenceKB = (this._byteLogs[this._byteLogs.length - 1].bytesReceived - this._byteLogs[0].bytesReceived) / 1000;
|
||||||
return bytesDifferenceKB / timeDifferenceSeconds;
|
return Math.round(bytesDifferenceKB / timeDifferenceSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
_calculateBytesLeft() {
|
_getBytesLeft() {
|
||||||
return this._bytesTotal - this._byteLogs[this._byteLogs.length - 1].bytesReceived;
|
return this._bytesTotal - this._byteLogs[this._byteLogs.length - 1].bytesReceived;
|
||||||
}
|
}
|
||||||
|
|
||||||
_calculateSecondsLeft() {
|
_getSecondsLeft() {
|
||||||
return Math.round(this._calculateBytesLeft() / this._calculateSpeedKbPerSecond() / 1000);
|
return Math.round(this._getBytesLeft() / this._getSpeedKbPerSecond() / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
_getSpeedString() {
|
_getSpeedString() {
|
||||||
const speedKBs = this._calculateSpeedKbPerSecond();
|
const speedKBs = this._getSpeedKbPerSecond();
|
||||||
|
|
||||||
if (speedKBs >= 1000) {
|
if (speedKBs >= 1000) {
|
||||||
let speedMBs = Math.round(speedKBs / 100) / 10;
|
let speedMBs = Math.round(speedKBs / 100) / 10;
|
||||||
return `${speedMBs} MB/s`; // e.g. "2.2 MB/s"
|
return `${speedMBs} MB/s`; // e.g. "2.2 MB/s"
|
||||||
|
@ -700,7 +701,7 @@ class Peer {
|
||||||
}
|
}
|
||||||
|
|
||||||
_getTimeString() {
|
_getTimeString() {
|
||||||
const seconds = this._calculateSecondsLeft();
|
const seconds = this._getSecondsLeft();
|
||||||
if (seconds > 60) {
|
if (seconds > 60) {
|
||||||
let minutes = Math.floor(seconds / 60);
|
let minutes = Math.floor(seconds / 60);
|
||||||
let secondsLeft = Math.floor(seconds % 60);
|
let secondsLeft = Math.floor(seconds % 60);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue