feat: implement performance view
All checks were successful
Deploy to GitHub Pages / build_site (push) Successful in 2m10s

This commit is contained in:
2024-04-25 03:37:52 +02:00
parent c28ef550a9
commit e0e1743b77
12 changed files with 421 additions and 179 deletions

View File

@ -114,3 +114,15 @@ export function withSubComponents<A, B extends Record<string, any>>(
});
return component as A & B;
}
export function humanizeNumber(number: number): string {
const suffixes = ["", "K", "M", "B", "T"];
if (number < 1000) {
return number.toString();
}
const numLength = Math.floor(Math.log10(number)) + 1;
const baseIndex = Math.floor((numLength - 1) / 3);
const base = Math.pow(10, baseIndex * 3);
const rounded = Math.round(number / base * 10) / 10;
return rounded + suffixes[baseIndex];
}