From 1cc591b247b9c46ef51d0d2066a90db9f919be4b Mon Sep 17 00:00:00 2001 From: Anthony Date: Mon, 27 Sep 2021 16:43:26 +0300 Subject: [PATCH] use a 1mb file for calculating bandwidth --- ui/analytics.js | 5 +++-- ui/util/detect-user-bandwidth.js | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ui/analytics.js b/ui/analytics.js index de25c7f5f..39ec740af 100644 --- a/ui/analytics.js +++ b/ui/analytics.js @@ -17,8 +17,8 @@ async function getUserBandwidth() { userDownloadBandwidthInBitsPerSecond = await getConnectionSpeed(); } -getUserBandwidth(); -setInterval(getUserBandwidth, 1000 * 30); +// get user bandwidth every minute, starting after an initial one minute wait +setInterval(getUserBandwidth, 1000 * 60); const isProduction = process.env.NODE_ENV === 'production'; const devInternalApis = process.env.LBRY_API_URL && process.env.LBRY_API_URL.includes('dev'); @@ -136,6 +136,7 @@ async function sendAndResetWatchmanData() { let timeSinceLastIntervalSend = new Date() - lastSentTime; lastSentTime = new Date(); + // TODO: hook into here to calculate bandwidth let protocol; if (videoType === 'application/x-mpegURL') { protocol = 'hls'; diff --git a/ui/util/detect-user-bandwidth.js b/ui/util/detect-user-bandwidth.js index 0610190fe..fd3f0d187 100644 --- a/ui/util/detect-user-bandwidth.js +++ b/ui/util/detect-user-bandwidth.js @@ -1,5 +1,5 @@ -const imageAddr = 'https://upload.wikimedia.org/wikipedia/commons/a/a6/Brandenburger_Tor_abends.jpg'; -const downloadSize = 2707459; // this must match with the image above +const imageAddr = 'https://upload.wikimedia.org/wikipedia/commons/b/b9/Pizigani_1367_Chart_1MB.jpg'; +const downloadSize = 1093957; // this must match with the image above let startTime, endTime; async function measureConnectionSpeed() {