time service contains bug, it cannot stop after edge

This commit is contained in:
Youmu Liu
2025-12-08 18:02:09 +08:00
parent 588fa867af
commit f960982bd3
17 changed files with 313 additions and 188 deletions
+37 -2
View File
@@ -25,10 +25,12 @@
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Common.Timing;
using StgSharp.HighPerformance;
using StgSharp.HighPerformance.Memory;
using StgSharp.Internal;
using StgSharp.Mathematics.Numeric;
using StgSharp.Timing;
namespace StgSharp
{
@@ -49,9 +51,9 @@ namespace StgSharp
// TestRender();
// TestHlsf();
// HlsfStressTest.Run();
M128 v = new M128();
/**/
/*
HybridLayerSegregatedFitAllocator hlsf;
unchecked {
hlsf = new((nuint)(64 * (ulong)10000 * 10000));
@@ -84,7 +86,40 @@ namespace StgSharp
Console.WriteLine();
}
/**/
// --- Logarithmic time sequence test: print seconds at each emitted span ---
// Configure a simple sequence:
// initial slice = 0.5s, total = 5s, growth multiplier = 2, min slice = 0.75s
TimeSequence seq =
/*
TimeSequence.CreateLogarithmic(initialSliceSeconds:0.5,
totalSeconds:5.0,
growthMultiplier:2.0,
minSliceSeconds:0.75);
/**/
TimeSequence.CreateLinear(5, 1);
/**/
// Bind to default time source provider.
TimeSpanProvider provider = new TimeSpanProvider(seq, TimeSpanProvider.DefaultProvider);
// Print the second mark when a span is emitted.
provider.TimeSpanRefreshed += (s, e) => {
// CurrentSecond is PreviousFrameTick / Frequency
Console.WriteLine($"span @ {provider.CurrentSecond:0.000}s");
};
// Start the time source and wait until sequence ends.
TimeSpanProvider.DefaultProvider.StartProvidingTime();
while (!provider.IsEnded) {
provider.WaitNextSpan();
}
TimeSpanProvider.DefaultProvider.StopProvidingTime();
// end of log-time sequence test
}
catch (Exception ex)
{