Skip to content

Commit

Permalink
Return bigint for bits/s
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoPolo committed Mar 1, 2023
1 parent 681d80c commit fa9a04b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/perf/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,16 @@ export class PerfService implements Startable {
}

// measureDownloadBandwidth returns the measured bandwidth in bits per second
async measureDownloadBandwidth (peer: PeerId, size: bigint): Promise<number> {
async measureDownloadBandwidth (peer: PeerId, size: bigint) {
const now = Date.now()
await this.startPerfOnStream(peer, 0n, size)
return (8 * Number(size)) / ((Date.now() - now) / 1000)
return (8n * size) / BigInt((Date.now() - now) / 1000)
}

// measureUploadBandwidth returns the measured bandwidth in bit per second
async measureUploadBandwidth (peer: PeerId, size: bigint) {
const now = Date.now()
await this.startPerfOnStream(peer, size, 0n)
return (8 * Number(size)) / ((Date.now() - now) / 1000)
return (8n * size) / BigInt((Date.now() - now) / 1000)
}
}

0 comments on commit fa9a04b

Please sign in to comment.