mirror of
https://github.com/Ellpeck/Coroutine.git
synced 2024-11-21 21:33:29 +01:00
Merge pull request #5 from zaafar/f/add-max-stat
added MaxMoveNextTime Stat to ActiveCoroutine.
This commit is contained in:
commit
1fec29dc63
2 changed files with 13 additions and 1 deletions
|
@ -33,6 +33,11 @@ namespace Coroutine {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int MoveNextCount { get; private set; }
|
public int MoveNextCount { get; private set; }
|
||||||
/// <summary>
|
/// <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.
|
/// 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.
|
/// This is the average amount of time that each "step", or each yield statement, of this coroutine took to execute.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -88,6 +93,10 @@ namespace Coroutine {
|
||||||
var result = this.enumerator.MoveNext();
|
var result = this.enumerator.MoveNext();
|
||||||
this.stopwatch.Stop();
|
this.stopwatch.Stop();
|
||||||
this.TotalMoveNextTime += this.stopwatch.Elapsed;
|
this.TotalMoveNextTime += this.stopwatch.Elapsed;
|
||||||
|
if (this.stopwatch.Elapsed > this.MaxMoveNextTime)
|
||||||
|
{
|
||||||
|
this.MaxMoveNextTime = this.stopwatch.Elapsed;
|
||||||
|
}
|
||||||
this.MoveNextCount++;
|
this.MoveNextCount++;
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
|
|
@ -50,7 +50,10 @@ namespace Test {
|
||||||
Console.WriteLine("The time is " + DateTime.Now);
|
Console.WriteLine("The time is " + DateTime.Now);
|
||||||
if (first.IsFinished) {
|
if (first.IsFinished) {
|
||||||
Console.WriteLine("By the way, the first coroutine has finished!");
|
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);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue