Skip to content

Commit

Permalink
Daemon fix network speed
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Aug 2, 2024
1 parent 642a35a commit 17d697e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions platforms/unix/hardwareinfo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ fn compare_sensor(prev_sensor: &CoresSensor, value: f64) -> CoresSensor {
pub fn refresh_hardware_info(data: &mut Data) {
let gb = 1024_f64.powi(3);
let mb = 1024_f64.powi(2);
let interval = 5.0;

// OS Info
if data.first_run {
Expand Down Expand Up @@ -564,11 +565,11 @@ pub fn refresh_hardware_info(data: &mut Data) {
if net_data.mac_address().to_string()
== data.hw_info.system.network.interfaces[0].mac_address
{
let download_data = net_data.total_received() as f64 / gb;
let upload_data = net_data.total_transmitted() as f64 / gb;
let download_data = (net_data.total_received() as f64 / gb).fmt_num();
let upload_data = (net_data.total_transmitted() as f64 / gb).fmt_num();

let throughput_download = net_data.received() as f64 / mb;
let throughput_upload = net_data.transmitted() as f64 / mb;
let throughput_download = net_data.received() as f64 / interval;
let throughput_upload = net_data.transmitted() as f64 / interval;

data.hw_info.system.network.interfaces[0].download_data = download_data;
data.hw_info.system.network.interfaces[0].upload_data = upload_data;
Expand Down

0 comments on commit 17d697e

Please sign in to comment.