added MaxMoveNextTime Stat to ActiveCoroutine.

This commit is contained in:
Zaafar 2021-01-01 00:21:17 -05:00
parent a77c9874e7
commit 013b846fbc
2 changed files with 13 additions and 1 deletions

View File

@ -33,6 +33,11 @@ namespace Coroutine {
/// </summary>
public int MoveNextCount { get; private set; }
/// <summary>
/// The maximum amount of time that <see cref="MoveNext"/> took.
/// This is the maximum amount of time that each "step", or each yield statement, of this coroutine took to execute.
/// </summary>
public TimeSpan MaxMoveNextTime { get; private set; }
/// <summary>
/// The average amount of time that <see cref="MoveNext"/> took.
/// This is the average amount of time that each "step", or each yield statement, of this coroutine took to execute.
/// </summary>
@ -88,6 +93,10 @@ namespace Coroutine {
var result = this.enumerator.MoveNext();
this.stopwatch.Stop();
this.TotalMoveNextTime += this.stopwatch.Elapsed;
if (this.stopwatch.Elapsed > this.MaxMoveNextTime)
{
this.MaxMoveNextTime = this.stopwatch.Elapsed;
}
this.MoveNextCount++;
if (!result) {

View File

@ -50,7 +50,10 @@ namespace Test {
Console.WriteLine("The time is " + DateTime.Now);
if (first.IsFinished) {
Console.WriteLine("By the way, the first coroutine has finished!");
Console.WriteLine($"{first.Name} data: {first.MoveNextCount} moves, {first.TotalMoveNextTime} total time, {first.AverageMoveNextTime} average");
Console.WriteLine($"{first.Name} data: {first.MoveNextCount} moves, " +
$"{first.TotalMoveNextTime.TotalMilliseconds} total time, " +
$"{first.AverageMoveNextTime.TotalMilliseconds} average, " +
$"{first.MaxMoveNextTime.TotalMilliseconds} maximum");
Environment.Exit(0);
}
}