Increased performance by factor two by removing all async parts
Closes #2
This commit is contained in:
30 files changed
+509
-532
No files matched your search
@@ -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;
|
||||
|
||||
|
||||
Reference in new issue
Block a user