Add speedtest page

This commit is contained in:
2024-02-19 19:49:34 +01:00
parent a9d685424f
commit 2e5f17d867
11 changed files with 353 additions and 5 deletions

View File

@@ -30,6 +30,24 @@ export const formatDataVolume = (amt, precision) => {
}
return amt + " B"
}
export const formatDataVolumeBits = (amt, precision) => {
amt = amt*8
if (precision < 3) { precision = 3; }
if (amt >= 1e18-1e15) {
return (amt/1e18).toPrecision(precision) + " Eb";
}else if (amt >= 1e15-1e12) {
return (amt/1e15).toPrecision(precision) + " Pb";
}else if (amt >= 1e12-1e9) {
return (amt/1e12).toPrecision(precision) + " Tb";
} else if (amt >= 1e9-1e6) {
return (amt/1e9).toPrecision(precision) + " Gb";
} else if (amt >= 1e6-1e3) {
return (amt/1e6).toPrecision(precision) + " Mb";
} else if (amt >= 1e3-1) {
return (amt/1e3).toPrecision(precision) + " kb";
}
return amt + " b"
}
const second = 1000
const minute = second*60