perf. profiling

This commit is contained in:
Christian Köllner 2020-04-21 19:02:18 +02:00
parent 65e87e5aa9
commit 78a62ddf98
3 changed files with 21 additions and 1 deletions

View File

@ -9,11 +9,12 @@
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
<PlatformTarget>x64</PlatformTarget>
<DefineConstants>SOTASK_PERF</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Capnp.Net.Runtime" Version="1.3.89-gdebe76be89" />
<PackageReference Include="CapnpC.CSharp.MsBuild.Generation" Version="1.3.89-gdebe76be89" />
<PackageReference Include="CapnpC.CSharp.MsBuild.Generation" Version="1.3.90-g65e87e5aa9" />
</ItemGroup>
</Project>

View File

@ -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
}
}
}

View File

@ -240,6 +240,9 @@ namespace Capnp.Util
}
}
/// <summary>
/// Performance profiling statistics
/// </summary>
public static readonly Statistics Stats = new Statistics();
#endif
/// <summary>