diff --git a/Benchmarking/CapnpProfile/CapnpProfile.csproj b/Benchmarking/CapnpProfile/CapnpProfile.csproj index f3757eb..3f857cb 100644 --- a/Benchmarking/CapnpProfile/CapnpProfile.csproj +++ b/Benchmarking/CapnpProfile/CapnpProfile.csproj @@ -9,11 +9,12 @@ full true x64 + SOTASK_PERF - + diff --git a/Benchmarking/CapnpProfile/Program.cs b/Benchmarking/CapnpProfile/Program.cs index 274bb97..f2ddd00 100644 --- a/Benchmarking/CapnpProfile/Program.cs +++ b/Benchmarking/CapnpProfile/Program.cs @@ -21,11 +21,27 @@ namespace CapnpProfile var payload = new byte[20]; new Random().NextBytes(payload); +#if SOTASK_PERF + int counter = 0; +#endif + while (true) { var result = await echoer.Echo(payload); if (result.Count != payload.Length) throw new InvalidOperationException("Echo server malfunction"); + +#if SOTASK_PERF + if (++counter == 1000) + { + counter = 0; + + Console.WriteLine($"StrictlyOrderedTask performance statistics:"); + Console.WriteLine($"AwaitInternal: max. {Capnp.Util.StrictlyOrderedTaskExtensions.Stats.AwaitInternalMaxOuterIterations} outer iterations"); + Console.WriteLine($"AwaitInternal: max. {Capnp.Util.StrictlyOrderedTaskExtensions.Stats.AwaitInternalMaxInnerIterations} inner iterations"); + Console.WriteLine($"OnCompleted: max. {Capnp.Util.StrictlyOrderedTaskExtensions.Stats.OnCompletedMaxSpins} iterations"); + } +#endif } } } diff --git a/Capnp.Net.Runtime/Util/StrictlyOrderedAwaitTask.cs b/Capnp.Net.Runtime/Util/StrictlyOrderedAwaitTask.cs index f86cf53..c5137c9 100644 --- a/Capnp.Net.Runtime/Util/StrictlyOrderedAwaitTask.cs +++ b/Capnp.Net.Runtime/Util/StrictlyOrderedAwaitTask.cs @@ -240,6 +240,9 @@ namespace Capnp.Util } } + /// + /// Performance profiling statistics + /// public static readonly Statistics Stats = new Statistics(); #endif ///