From fa9a04b24a6b3df67b99f9afff6d86fe0f1a8737 Mon Sep 17 00:00:00 2001 From: Marco Munizaga Date: Tue, 28 Feb 2023 20:57:12 -0800 Subject: [PATCH] Return bigint for bits/s --- src/perf/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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) } }