Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved progress reporting and memory usage #16

Merged
merged 1 commit into from
Sep 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Benchmarker/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private static void Main(string[] args)
}
});
#else
options = new Options {Benchmark = "AVX", Threads = 1, Runs = 1};
options = new Options {Benchmark = "BZIP2", Threads = 1, Runs = 1};
#endif
var runner = new BenchmarkRunner(options);

Expand All @@ -57,7 +57,16 @@ private static void Main(string[] args)
}
}, ct.Token);

runner.RunBenchmark();
try
{
runner.RunBenchmark();
}
catch (ArgumentException e)
{
Console.WriteLine(e.Message);

return;
}

progress.Report(1.0d);

Expand Down
15 changes: 11 additions & 4 deletions Benchmarking/Arithmetic/Integer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ internal class Integer : Benchmark
{
// 200 "MB"
private const int LENGTH = 200000000;
private readonly byte[] resultByteArray = new byte[LENGTH];
private readonly int[] resultIntArray = new int[LENGTH];
private readonly long[] resultLongArray = new long[LENGTH];
private readonly short[] resultShortArray = new short[LENGTH];
private byte[] resultByteArray;
private int[] resultIntArray;
private long[] resultLongArray;
private short[] resultShortArray;

private byte randomByte;
private int randomInt;
Expand Down Expand Up @@ -188,6 +188,8 @@ public override void Run()
{
resultLongArray[j] = Math.BigMul(randomInt, randomInt);
}

BenchmarkRunner.ReportProgress();
});
}

Expand Down Expand Up @@ -217,6 +219,11 @@ public override void Initialize()
randomByte = (byte) rand.Next();
randomLong = (long) int.MaxValue + rand.Next();
randomShort = (short) rand.Next();

resultByteArray = new byte[LENGTH];
resultIntArray = new int[LENGTH];
resultLongArray = new long[LENGTH];
resultShortArray = new short[LENGTH];
}
}
}
5 changes: 0 additions & 5 deletions Benchmarking/Benchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,5 @@ public virtual double GetReferenceValue()
{
return 0.0d;
}

public virtual void PostRun()
{
BenchmarkRunner.ReportProgress();
}
}
}
2 changes: 2 additions & 0 deletions Benchmarking/Compression/BZip2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public override void Run()
}
}
}

BenchmarkRunner.ReportProgress();
});
}

Expand Down
2 changes: 2 additions & 0 deletions Benchmarking/Compression/Deflate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public override void Run()
}
}
}

BenchmarkRunner.ReportProgress();
});
}

Expand Down
2 changes: 2 additions & 0 deletions Benchmarking/Compression/GZip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public override void Run()
}
}
}

BenchmarkRunner.ReportProgress();
});
}

Expand Down
2 changes: 2 additions & 0 deletions Benchmarking/Compression/ZIP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public override void Run()
}
}
}

BenchmarkRunner.ReportProgress();
});
}

Expand Down
11 changes: 6 additions & 5 deletions Benchmarking/Extension/AVX.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;

#if NETCOREAPP3_0
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;

#endif

#endregion
Expand Down Expand Up @@ -44,12 +42,14 @@ public override void Run()
var randomFloatingSpan = new Span<float>(new[] {randomFloatingNumber});
var dst = new Span<float>(datas[i1]);

int iterations = 1000000000 / options.Threads;
var iterations = 1000000000 / options.Threads;

for (var j = 0; j < iterations; j++)
{
AddScalarU(randomFloatingSpan, dst);
}

BenchmarkRunner.ReportProgress();
});
}

Expand Down Expand Up @@ -120,6 +120,7 @@ private unsafe void AssignScalarU(Span<float> scalar, Span<float> dst)
}
}
}

private unsafe void AddScalarU(Span<float> scalar, Span<float> dst)
{
fixed (float* pdst = dst)
Expand Down Expand Up @@ -162,4 +163,4 @@ private unsafe void AddScalarU(Span<float> scalar, Span<float> dst)
}
#endif
}
}
}