Updated benchmark code

このコミットが含まれているのは:
Sergio Pedri committed 2019-08-17 22:33:19 +02:00
1 親 a4887066a4
コミット ab9d5944dc
1ファイル変更
+34 -3
+34 -3
ファイルの表示
@@ -7,12 +7,17 @@ namespace ComputeSharp.Benchmark
{
static void Main()
{
var benchmark = new FullyConnectedLayerBenchmark();
benchmark.Gpu(); // Warmup
using var benchmark = new FullyConnectedLayerBenchmark();
Console.WriteLine("======== WARMUP ========");
benchmark.GpuWithNoTemporaryBuffers(); // Warmup
Console.WriteLine();
Console.WriteLine("======== GPU with temporary buffer ========");
Stopwatch timer = Stopwatch.StartNew();
TimeSpan cpuTime = TimeSpan.Zero, gpuTime = TimeSpan.Zero;
// GPU with temporary buffers
for (int i = 0; i < 10; i++)
{
benchmark.Cpu();
@@ -20,12 +25,38 @@ namespace ComputeSharp.Benchmark
Console.WriteLine($"CPU: {timer.Elapsed:g}");
timer.Restart();
benchmark.Gpu();
benchmark.GpuWithTemporaryBuffers();
gpuTime += timer.Elapsed;
Console.WriteLine($"GPU: {timer.Elapsed:g}");
timer.Restart();
}
Console.WriteLine();
Console.WriteLine("======== AVERAGE ========");
Console.WriteLine($"CPU: {cpuTime / 10:g}");
Console.WriteLine($"GPU: {gpuTime / 10:g}");
Console.WriteLine("=========================");
Console.WriteLine();
Console.WriteLine("======== GPU with no temporary buffer ========");
timer = Stopwatch.StartNew();
cpuTime = gpuTime = TimeSpan.Zero;
// GPU with no temporary buffers
for (int i = 0; i < 10; i++)
{
benchmark.Cpu();
cpuTime += timer.Elapsed;
Console.WriteLine($"CPU: {timer.Elapsed:g}");
timer.Restart();
benchmark.GpuWithNoTemporaryBuffers();
gpuTime += timer.Elapsed;
Console.WriteLine($"GPU: {timer.Elapsed:g}");
timer.Restart();
}
Console.WriteLine();
Console.WriteLine("======== AVERAGE ========");
Console.WriteLine($"CPU: {cpuTime / 10:g}");
Console.WriteLine($"GPU: {gpuTime / 10:g}");