From 013b846fbc0a8b5167baf727abf6357cd7a39dc8 Mon Sep 17 00:00:00 2001 From: Zaafar Date: Fri, 1 Jan 2021 00:21:17 -0500 Subject: [PATCH] added MaxMoveNextTime Stat to ActiveCoroutine. --- Coroutine/ActiveCoroutine.cs | 9 +++++++++ Test/Example.cs | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Coroutine/ActiveCoroutine.cs b/Coroutine/ActiveCoroutine.cs index 354f1cf..e6067c8 100644 --- a/Coroutine/ActiveCoroutine.cs +++ b/Coroutine/ActiveCoroutine.cs @@ -33,6 +33,11 @@ namespace Coroutine { /// public int MoveNextCount { get; private set; } /// + /// The maximum amount of time that took. + /// This is the maximum amount of time that each "step", or each yield statement, of this coroutine took to execute. + /// + public TimeSpan MaxMoveNextTime { get; private set; } + /// /// The average amount of time that took. /// This is the average amount of time that each "step", or each yield statement, of this coroutine took to execute. /// @@ -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) { diff --git a/Test/Example.cs b/Test/Example.cs index 4b29b9a..380d908 100644 --- a/Test/Example.cs +++ b/Test/Example.cs @@ -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); } }