Does anyone know a more efficient way of doing this code:
public static float ConvertTrafficValues(double bytes, out string speedBytes)
{
if (bytes >= 1000000)
{
bytes /= 1000000;
bytes = Math.Round(bytes, 1);
speedBytes = "MB/s";
}
else if (bytes >= 1000)
{
bytes /= 1000;
bytes = Math.Round(bytes, 0);
speedBytes = "KB/s";
}
else
{
bytes = Math.Round(bytes, 0);
speedBytes = "B/s";
}
return (float)bytes;
}
Im calling this multiple times every second alongside with some other things and I need it to be as efficient as possible