feat: add total memory usage to dev bar

This commit is contained in:
goat 2022-01-25 21:50:31 +01:00
parent 29a39b4be1
commit 1083c2f95e
No known key found for this signature in database
GPG key ID: 7773BB5B43BA52E5
3 changed files with 21 additions and 19 deletions

View file

@ -335,6 +335,24 @@ namespace Dalamud.Utility
if (exit)
Environment.Exit(-1);
}
/// <summary>
/// Transform byte count to human readable format.
/// </summary>
/// <param name="bytes">Number of bytes.</param>
/// <returns>Human readable version.</returns>
public static string FormatBytes(long bytes)
{
string[] suffix = { "B", "KB", "MB", "GB", "TB" };
int i;
double dblSByte = bytes;
for (i = 0; i < suffix.Length && bytes >= 1024; i++, bytes /= 1024)
{
dblSByte = bytes / 1024.0;
}
return $"{dblSByte:0.##} {suffix[i]}";
}
/// <summary>
/// Retrieve a UTF8 string from a null terminated byte array.