From b51dbf33fd063129282e2015a071044f672d40fc Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Mon, 23 Jan 2017 01:53:34 +0100 Subject: [PATCH] verifying Vector.IsHardwareAccelerated in tests and benchmarks --- .../Image/MultiImageBenchmarkBase.cs | 4 ++++ tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj | 4 ++++ tests/ImageSharp.Sandbox46/packages.config | 1 + .../Formats/Jpg/JpegProfilingBenchmarks.cs | 8 +++++++- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/ImageSharp.Benchmarks/Image/MultiImageBenchmarkBase.cs b/tests/ImageSharp.Benchmarks/Image/MultiImageBenchmarkBase.cs index 9007ef75b..26aad07b8 100644 --- a/tests/ImageSharp.Benchmarks/Image/MultiImageBenchmarkBase.cs +++ b/tests/ImageSharp.Benchmarks/Image/MultiImageBenchmarkBase.cs @@ -86,6 +86,10 @@ namespace ImageSharp.Benchmarks.Image [Setup] public void ReadImages() { + if (!Vector.IsHardwareAccelerated) + { + throw new Exception("Vector.IsHardwareAccelerated == false! Check your build settings!"); + } // Console.WriteLine("Vector.IsHardwareAccelerated: " + Vector.IsHardwareAccelerated); this.ReadFilesImpl(); } diff --git a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj index 7994456da..ab46034d1 100644 --- a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj +++ b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj @@ -41,6 +41,10 @@ + + ..\..\packages\System.Numerics.Vectors.4.1.1\lib\net46\System.Numerics.Vectors.dll + True + diff --git a/tests/ImageSharp.Sandbox46/packages.config b/tests/ImageSharp.Sandbox46/packages.config index 8b4f34078..8163e6e2e 100644 --- a/tests/ImageSharp.Sandbox46/packages.config +++ b/tests/ImageSharp.Sandbox46/packages.config @@ -1,5 +1,6 @@  + diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs index eb9747cce..64528d4ac 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs @@ -8,6 +8,7 @@ namespace ImageSharp.Tests using System; using System.IO; using System.Linq; + using System.Numerics; using ImageSharp.Formats; @@ -30,11 +31,16 @@ namespace ImageSharp.Tests [InlineData(30, TestImages.Jpeg.Baseline.Jpeg444)] public void DecodeJpeg(int executionCount, string fileName) { + if (!Vector.IsHardwareAccelerated) + { + throw new Exception("Vector.IsHardwareAccelerated == false! (Wrong build?)"); + } + string path = TestFile.GetPath(fileName); byte[] bytes = File.ReadAllBytes(path); this.Measure( - 100, + executionCount, () => { Image img = new Image(bytes);