|
|
@ -8,7 +8,7 @@ namespace SemiColinGames { |
|
|
|
private readonly double targetTime; |
|
|
|
private readonly string name; |
|
|
|
private double startTime = 0.0; |
|
|
|
private int[] histogram = new int[41]; |
|
|
|
private int[] histogram = new int[21]; |
|
|
|
private int totalFrames = 0; |
|
|
|
|
|
|
|
public Timer(double targetTime, string name) { |
|
|
@ -25,7 +25,7 @@ namespace SemiColinGames { |
|
|
|
stopwatch.Stop(); |
|
|
|
totalFrames++; |
|
|
|
double frameTime = stopwatch.Elapsed.TotalSeconds - startTime; |
|
|
|
int bucket = FMath.Clamp((int) (5.0f * frameTime / targetTime), 0, 40); |
|
|
|
int bucket = FMath.Clamp((int) (10.0f * frameTime / targetTime), 0, 20); |
|
|
|
histogram[bucket]++; |
|
|
|
if (totalFrames % 100 == 0) { |
|
|
|
DumpStats(); |
|
|
@ -34,13 +34,20 @@ namespace SemiColinGames { |
|
|
|
|
|
|
|
public void DumpStats() { |
|
|
|
Debug.WriteLine(name + ".DumpStats():"); |
|
|
|
for (int i = 0; i < histogram.Length - 1; i++) { |
|
|
|
for (int i = 0; i < histogram.Length; i++) { |
|
|
|
int value = histogram[i]; |
|
|
|
if (value > 0) { |
|
|
|
Debug.WriteLine($"{i * 5}-{(i + 1) * 5}%: {histogram[i]}"); |
|
|
|
if (value == 0) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
// 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); |
|
|
|
if (i == histogram.Length - 1) { |
|
|
|
prefix = " 200%+: "; |
|
|
|
} |
|
|
|
string stars = new string('*', numStars); |
|
|
|
Debug.WriteLine(String.Format("{0}{1,-100} {2}", prefix, stars, value)); |
|
|
|
} |
|
|
|
Debug.WriteLine($"200+%: {histogram[histogram.Length - 1]}"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |