Skip to content

Commit

Permalink
Fixes a crasher
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoreymendez committed May 15, 2024
1 parent 7d5ddc9 commit 923eefc
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,16 @@ final class NetworkProtectionConnectionBandwidthAnalyzer {

private func bytesPerSecond(newer: Snapshot, older: Snapshot) -> (rx: Double, tx: Double) {
let deltaSeconds = newer.date.timeIntervalSince1970 - older.date.timeIntervalSince1970
let rx = Double(newer.rxBytes - older.rxBytes) / deltaSeconds
let tx = Double(newer.txBytes - older.txBytes) / deltaSeconds
let rx: Double
let tx: Double

if deltaSeconds > 0 {
rx = Double(newer.rxBytes - older.rxBytes) / deltaSeconds
tx = Double(newer.txBytes - older.txBytes) / deltaSeconds
} else {
rx = 0
tx = 0
}

return (rx, tx)
}
Expand Down

0 comments on commit 923eefc

Please sign in to comment.