mirror of
https://github.com/Ellpeck/Coroutine.git
synced 2024-06-02 14:03:37 +02:00
added function to reset stats.
This commit is contained in:
parent
0e5b571590
commit
7aa96de6e9
|
@ -81,6 +81,15 @@ namespace Coroutine {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reset statistics related to this coroutine.
|
||||||
|
/// </summary>
|
||||||
|
public void ResetStats() {
|
||||||
|
this.TotalMoveNextTime = TimeSpan.Zero;
|
||||||
|
this.MoveNextCount = 1;
|
||||||
|
this.MaxMoveNextTime = TimeSpan.Zero;
|
||||||
|
}
|
||||||
|
|
||||||
internal bool Tick(double deltaSeconds) {
|
internal bool Tick(double deltaSeconds) {
|
||||||
if (!this.WasCanceled && this.current.Tick(deltaSeconds))
|
if (!this.WasCanceled && this.current.Tick(deltaSeconds))
|
||||||
this.MoveNext();
|
this.MoveNext();
|
||||||
|
|
|
@ -335,6 +335,10 @@ namespace Tests {
|
||||||
var gTc = cr.MaxMoveNextTime.Milliseconds > expected2 - errorbar2; // 95% accuracy.
|
var gTc = cr.MaxMoveNextTime.Milliseconds > expected2 - errorbar2; // 95% accuracy.
|
||||||
var lTd = cr.MaxMoveNextTime.Milliseconds < expected2 + errorbar2; // 95% accuracy.
|
var lTd = cr.MaxMoveNextTime.Milliseconds < expected2 + errorbar2; // 95% accuracy.
|
||||||
Assert.IsTrue(gTc && lTd, $"Maximum Move Next Time {cr.MaxMoveNextTime.Milliseconds} is invalid.");
|
Assert.IsTrue(gTc && lTd, $"Maximum Move Next Time {cr.MaxMoveNextTime.Milliseconds} is invalid.");
|
||||||
|
|
||||||
|
cr.ResetStats();
|
||||||
|
Assert.IsTrue(cr.AverageMoveNextTime.Milliseconds == 0, "Invalid Coroutine Statistics.");
|
||||||
|
Assert.IsTrue(cr.MaxMoveNextTime.Milliseconds == 0, "Invalid Coroutine Statistics.");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|
Loading…
Reference in a new issue