diff --git a/src/perf/index.ts b/src/perf/index.ts index 4c72715a44..bb5d4aba2d 100644 --- a/src/perf/index.ts +++ b/src/perf/index.ts @@ -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 { + 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) } }