Merge pull request #5 from zaafar/f/add-max-stat

added MaxMoveNextTime Stat to ActiveCoroutine.
This commit is contained in:
Ell 2021-01-01 11:07:53 +01:00 committed by GitHub
commit 1fec29dc63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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);
}
}