Timer: don't automatically DumpStats(); refactor string prefixes during dump

GitOrigin-RevId: 93b7d652823785b2be1074af50dbe4952e288856
This commit is contained in:
Colin McMillen 2020-02-04 09:54:21 -05:00
parent 5672e292cc
commit d30be7a460

View File

@ -27,9 +27,6 @@ namespace SemiColinGames {
double frameTime = stopwatch.Elapsed.TotalSeconds - startTime;
int bucket = FMath.Clamp((int) (10.0f * frameTime / targetTime), 0, 20);
histogram[bucket]++;
if (totalFrames % 100 == 0) {
DumpStats();
}
}
public void DumpStats() {
@ -41,9 +38,11 @@ namespace SemiColinGames {
}
// Every star is one percent.
int numStars = FMath.Clamp(100 * value / totalFrames, 1, 100);
string prefix = String.Format("{0,3}-{1,3}%: ", i * 10, (i + 1) * 10);
string prefix;
if (i == histogram.Length - 1) {
prefix = " 200+%: ";
} else {
prefix = String.Format("{0,3}-{1,3}%: ", i * 10, (i + 1) * 10);
}
string stars = new string('*', numStars);
Debug.WriteLine(String.Format("{0}{1,-100} {2}", prefix, stars, value));