From 42b3639d5cc9b1c3da66b6395b7c006f56406a69 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 24 Oct 2016 12:05:17 +1100 Subject: [PATCH] Cleanup benchmarks Former-commit-id: 2e9c25a66e2d6125f1dbaf143544c147b024c32c Former-commit-id: 62f3d61bc6faa7535a371c782879e413c3e30bfa Former-commit-id: cab675a891e4b30bfe8029046f3431c973dd1eb7 --- .../General/ArrayCopy.cs | 23 ++++++++------- .../Samplers/Crop.cs | 3 +- .../Samplers/DetectEdges.cs | 29 +++++++++---------- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/tests/ImageProcessorCore.Benchmarks/General/ArrayCopy.cs b/tests/ImageProcessorCore.Benchmarks/General/ArrayCopy.cs index c1ada94ba6..99e5263ff2 100644 --- a/tests/ImageProcessorCore.Benchmarks/General/ArrayCopy.cs +++ b/tests/ImageProcessorCore.Benchmarks/General/ArrayCopy.cs @@ -2,7 +2,6 @@ // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // - namespace ImageProcessorCore.Benchmarks.General { using System; @@ -15,38 +14,40 @@ namespace ImageProcessorCore.Benchmarks.General [Params(100, 1000, 10000)] public int Count { get; set; } - byte[] source, destination; + byte[] source; + + byte[] destination; [Setup] public void SetUp() { - source = new byte[Count]; - destination = new byte[Count]; + this.source = new byte[this.Count]; + this.destination = new byte[this.Count]; } [Benchmark(Baseline = true, Description = "Copy using Array.Copy()")] public void CopyArray() { - Array.Copy(source, destination, Count); + Array.Copy(this.source, this.destination, this.Count); } [Benchmark(Description = "Copy using Unsafe")] public unsafe void CopyUnsafe() { - fixed (byte* pinnedDestination = destination) - fixed (byte* pinnedSource = source) + fixed (byte* pinnedDestination = this.destination) + fixed (byte* pinnedSource = this.source) { - Unsafe.CopyBlock(pinnedSource, pinnedDestination, (uint)Count); + Unsafe.CopyBlock(pinnedSource, pinnedDestination, (uint)this.Count); } } [Benchmark(Description = "Copy using Buffer.MemoryCopy")] public unsafe void CopyUsingBufferMemoryCopy() { - fixed (byte* pinnedDestination = destination) - fixed (byte* pinnedSource = source) + fixed (byte* pinnedDestination = this.destination) + fixed (byte* pinnedSource = this.source) { - Buffer.MemoryCopy(pinnedSource, pinnedDestination, Count, Count); + Buffer.MemoryCopy(pinnedSource, pinnedDestination, this.Count, this.Count); } } } diff --git a/tests/ImageProcessorCore.Benchmarks/Samplers/Crop.cs b/tests/ImageProcessorCore.Benchmarks/Samplers/Crop.cs index 07d7002e61..410dc8c826 100644 --- a/tests/ImageProcessorCore.Benchmarks/Samplers/Crop.cs +++ b/tests/ImageProcessorCore.Benchmarks/Samplers/Crop.cs @@ -9,8 +9,9 @@ namespace ImageProcessorCore.Benchmarks using System.Drawing.Drawing2D; using BenchmarkDotNet.Attributes; - using CoreSize = ImageProcessorCore.Size; + using CoreImage = ImageProcessorCore.Image; + using CoreSize = ImageProcessorCore.Size; public class Crop { diff --git a/tests/ImageProcessorCore.Benchmarks/Samplers/DetectEdges.cs b/tests/ImageProcessorCore.Benchmarks/Samplers/DetectEdges.cs index 4573587f22..f69e3727cb 100644 --- a/tests/ImageProcessorCore.Benchmarks/Samplers/DetectEdges.cs +++ b/tests/ImageProcessorCore.Benchmarks/Samplers/DetectEdges.cs @@ -3,7 +3,6 @@ // Licensed under the Apache License, Version 2.0. // - namespace ImageProcessorCore.Benchmarks { using System.IO; @@ -19,11 +18,11 @@ namespace ImageProcessorCore.Benchmarks [Setup] public void ReadImage() { - if (image == null) + if (this.image == null) { - using(FileStream stream = File.OpenRead("../ImageProcessorCore.Tests/TestImages/Formats/Bmp/Car.bmp")) + using (FileStream stream = File.OpenRead("../ImageProcessorCore.Tests/TestImages/Formats/Bmp/Car.bmp")) { - image = new CoreImage(stream); + this.image = new CoreImage(stream); } } } @@ -31,17 +30,17 @@ namespace ImageProcessorCore.Benchmarks [Benchmark(Description = "ImageProcessorCore DetectEdges")] public void ImageProcessorCoreDetectEdges() { - image.DetectEdges(EdgeDetection.Kayyali); - image.DetectEdges(EdgeDetection.Kayyali); - image.DetectEdges(EdgeDetection.Kirsch); - image.DetectEdges(EdgeDetection.Lapacian3X3); - image.DetectEdges(EdgeDetection.Lapacian5X5); - image.DetectEdges(EdgeDetection.LaplacianOfGaussian); - image.DetectEdges(EdgeDetection.Prewitt); - image.DetectEdges(EdgeDetection.RobertsCross); - image.DetectEdges(EdgeDetection.Robinson); - image.DetectEdges(EdgeDetection.Scharr); - image.DetectEdges(EdgeDetection.Sobel); + this.image.DetectEdges(EdgeDetection.Kayyali); + this.image.DetectEdges(EdgeDetection.Kayyali); + this.image.DetectEdges(EdgeDetection.Kirsch); + this.image.DetectEdges(EdgeDetection.Lapacian3X3); + this.image.DetectEdges(EdgeDetection.Lapacian5X5); + this.image.DetectEdges(EdgeDetection.LaplacianOfGaussian); + this.image.DetectEdges(EdgeDetection.Prewitt); + this.image.DetectEdges(EdgeDetection.RobertsCross); + this.image.DetectEdges(EdgeDetection.Robinson); + this.image.DetectEdges(EdgeDetection.Scharr); + this.image.DetectEdges(EdgeDetection.Sobel); } } }