This repository has been archived by the owner on Apr 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: add session data consumption information in GUI/text UIs (#287)
* Feature: add session data consumption information in GUI/text UIs Adds the total bytes downloaded and uploaded in the current session as well as the average data transfer rate for both UL/DL. The information is not added to the 1-line UI as the line will take 150+ characters in the screen.
- Loading branch information
Showing
9 changed files
with
126 additions
and
10 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.sheepit.client; | ||
|
||
import lombok.AllArgsConstructor; | ||
|
||
/**************** | ||
* Holds the session traffic statistics. The constructor accepts two parameters: | ||
* @long bytes - bytes transferred in the session | ||
* @Job seconds - seconds spent transferring the data | ||
*/ | ||
@AllArgsConstructor | ||
public class TransferStats { | ||
private long bytes; | ||
private long millis; | ||
|
||
public TransferStats() { | ||
this.bytes = 0; | ||
this.millis = 0; | ||
} | ||
|
||
public void calc(long bytes, long millis) { | ||
this.bytes += bytes; | ||
this.millis += millis; | ||
} | ||
|
||
public String getSessionTraffic() { | ||
return Utils.formatDataConsumption(this.bytes); | ||
} | ||
|
||
public String getAverageSessionSpeed() { | ||
try { | ||
return Utils.formatDataConsumption((long) (this.bytes / (this.millis / 1000f))); | ||
} catch (ArithmeticException e) { // Unlikely, but potential division by zero fallback if first transfer is done in zero millis | ||
return Utils.formatDataConsumption((long) (this.bytes / (0.1f))); | ||
} | ||
} | ||
} |
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
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
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
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
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