mlab-speedtest
mlab-speedtest copied to clipboard
Results interface may incorrectly reports throughput units
A user reported that their internet connection is supposed to be 12Mbps down and 1Mbps up, but, when testing, the interface reports the upload speed as "0.92 kb/s". They flagged this as a probable bug in our code, and that it likely should be reading "0.92 Mb/s".
Looking at the code that renders this display value, it does appear that there is an issue. When determining the unit for the speed result the code assumes that the value it is working with is Kb/s. However, the value that is getting passed into that function, has already been converted (roughly) from Kb/s to Mb/s.
The easy fix for this, I believe, is to simply stop using the getSpeedUnit()
function and to fix the unit Mb/s. Speeds are advertised, usually, as Mbps, and so, even if this worked, reported Kbps or Gbps (Tbps?) may not be useful to a user.
The conversion you see from Kb to Mb ( https://github.com/m-lab/mlab-speedtest/blob/master/app/assets/js/ndt-wrapper.js#L181 ) is, I thought, actually a conversion from b to Kb?
It looks to me as if c2sRate
is kilobytes:
https://github.com/m-lab/mlab-speedtest/blob/master/app/assets/js/ndt-browser-client.js#L240
You win! I had forgotten about that /1000 in there.
I think your solution is correct, but it did not remove enough code - we also need to delete the use of the "justified" function. I'll comment further there.