Increased performance by factor two by removing all async parts

Closes #2
This commit is contained in:
Thorsten Sommer committed 2023-07-10 16:39:23 +02:00
1 parent 1c28a57c06
commit d0eca012ce
30 files changed
+509 -532

No files matched your search

+3 -3
View File
@@ -50,11 +50,11 @@ public sealed class ShapeFitter<TNum> where TNum : IFloatingPointIeee754<TNum>,
/// </summary>
/// <param name="token">An optional cancellation token.</param>
/// <returns>The next value regarding the given shape.</returns>
public async ValueTask<TNum> NextNumber(CancellationToken token = default)
public TNum NextNumber(CancellationToken token = default)
{
while (!token.IsCancellationRequested)
{
var x = await this.rng.GetUniform(token);
var x = this.rng.GetUniform(token);
if (TNum.IsNaN(x))
return x;
@@ -63,7 +63,7 @@ public sealed class ShapeFitter<TNum> where TNum : IFloatingPointIeee754<TNum>,
nextBucket = this.probabilities.Length - 1;
var threshold = this.probabilities[nextBucket];
var y = await this.uniform.NextNumber(TNum.Zero, this.max, token);
var y = this.uniform.NextNumber(TNum.Zero, this.max, token);
if (TNum.IsNaN(y))
return y;