1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 19:48:20 +02:00

Time format fixes

This commit is contained in:
Brian Fiete 2022-04-30 09:34:25 -07:00
parent a874bab0e4
commit 01112c54fe
2 changed files with 9 additions and 9 deletions

View file

@ -708,19 +708,19 @@ namespace BeefPerf
if (intTimeUS < 1000) // < 1ms if (intTimeUS < 1000) // < 1ms
{ {
int32 timeNS = (int32)((timeUS - intTimeUS) * 1000); int32 timeNS = (int32)((timeUS - intTimeUS) * 1000);
str.AppendF("{0}.{1:02}us", intTimeUS, timeNS / 10); str.AppendF("{0}.{1:00}us", intTimeUS, timeNS / 10);
} }
else if (intTimeUS < 1000*1000) // < 1s else if (intTimeUS < 1000*1000) // < 1s
{ {
str.AppendF("{0}.{1:02}ms", (int32)(intTimeUS / 1000), (int32)((intTimeUS / 10) % 100)); str.AppendF("{0}.{1:00}ms", (int32)(intTimeUS / 1000), (int32)((intTimeUS / 10) % 100));
} }
else if (intTimeUS < 10*1000*1000) // < 10s else if (intTimeUS < 10*1000*1000) // < 10s
{ {
str.AppendF("{0}s:{1:03}.{2:01}ms", (int32)(intTimeUS / 1000 / 1000), (int32)((intTimeUS / 1000) % 1000), (int32)((intTimeUS / 100) % 10)); str.AppendF("{0}s:{1:000}.{2:00}ms", (int32)(intTimeUS / 1000 / 1000), (int32)((intTimeUS / 1000) % 1000), (int32)((intTimeUS / 100) % 10));
} }
else if (intTimeUS < 60*1000*1000) // < 1m else if (intTimeUS < 60*1000*1000) // < 1m
{ {
str.AppendF("{0}s:{1:03}ms", (int32)(intTimeUS / 1000 / 1000), (int32)((intTimeUS / 1000) % 1000)); str.AppendF("{0}s:{1:000}ms", (int32)(intTimeUS / 1000 / 1000), (int32)((intTimeUS / 1000) % 1000));
} }
else else
{ {
@ -731,11 +731,11 @@ namespace BeefPerf
public static void TimeToStr(double timeUS, String str, bool highPrecision = true) public static void TimeToStr(double timeUS, String str, bool highPrecision = true)
{ {
int64 intTimeUS = (int64)timeUS; int64 intTimeUS = (int64)timeUS;
str.AppendF("{0}:{1:02}:", (int32)((intTimeUS / 60 / 60 / 1000000)), (int32)((intTimeUS / 60 / 1000000) % 60)); str.AppendF("{0}:{1:00}:", (int32)((intTimeUS / 60 / 60 / 1000000)), (int32)((intTimeUS / 60 / 1000000) % 60));
if (highPrecision) if (highPrecision)
str.AppendF("{0:02}.{1:06}", (int32)((intTimeUS / 1000000) % 60), (int32)((intTimeUS % 1000000))); str.AppendF("{0:00}.{1:000000}", (int32)((intTimeUS / 1000000) % 60), (int32)((intTimeUS % 1000000)));
else else
str.AppendF("{0:02}.{1:02}", (int32)((intTimeUS / 1000000) % 60), (int32)((intTimeUS / 10000 % 100))); str.AppendF("{0:00}.{1:00}", (int32)((intTimeUS / 1000000) % 60), (int32)((intTimeUS / 10000 % 100)));
} }
public Result<int64> ParseTime(String str) public Result<int64> ParseTime(String str)

View file

@ -1323,14 +1323,14 @@ namespace BeefPerf
//0:00:03.123456 {with zeroes trimmed} //0:00:03.123456 {with zeroes trimmed}
str.AppendF("{0}:{1:02}:", (int32)((timeUS / 60 / 60 / 1000000)), (int32)((timeUS / 60 / 1000000) % 60)); str.AppendF("{0}:{1:00}:", (int32)((timeUS / 60 / 60 / 1000000)), (int32)((timeUS / 60 / 1000000) % 60));
using (g.PushColor(0x80FFFFFF)) using (g.PushColor(0x80FFFFFF))
g.DrawString(str, xOfs + 4, -2); g.DrawString(str, xOfs + 4, -2);
xOfs += g.mFont.GetWidth(str); xOfs += g.mFont.GetWidth(str);
str.Clear(); str.Clear();
str.AppendF("{0:02}.{1:06}", (int32)((timeUS / 1000000) % 60), (int32)((timeUS % 1000000))); str.AppendF("{0:00}.{1:000000}", (int32)((timeUS / 1000000) % 60), (int32)((timeUS % 1000000)));
int maxTrim = 0; int maxTrim = 0;
if (pixelsPerUS < 0.012) if (pixelsPerUS < 0.012)