Browse Source

Add benchmarking

Former-commit-id: b49aa6d4012cc28d93b0f2c680d4de6d10aa09bb
Former-commit-id: a59176e8bda26889d71fde5d239837bc0994ce79
Former-commit-id: 2a7361abe1a31ab578c0b85d0492eacea12cb8a4
af/merge-core
James Jackson-South 10 years ago
parent
commit
17bc2ad05f
  1. 5
      .gitignore
  2. 15
      ImageProcessorCore.sln
  3. 1
      src/ImageProcessorCore/Properties/AssemblyInfo.cs
  4. 9
      src/ImageProcessorCore/project.json
  5. 20
      tests/ImageProcessorCore.Benchmarks/ImageProcessorCore.Benchmarks.xproj
  6. 26
      tests/ImageProcessorCore.Benchmarks/Program.cs
  7. 23
      tests/ImageProcessorCore.Benchmarks/Properties/AssemblyInfo.cs
  8. 44
      tests/ImageProcessorCore.Benchmarks/Resize.cs
  9. 29
      tests/ImageProcessorCore.Benchmarks/project.json

5
.gitignore

@ -205,4 +205,7 @@ FakesAssemblies/
# ASP.NET 5 # ASP.NET 5
project.lock.json project.lock.json
artifacts/ artifacts/
#BenchmarkDotNet
**/BenchmarkDotNet.Artifacts/

15
ImageProcessorCore.sln

@ -12,6 +12,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionIt
README.md = README.md README.md = README.md
EndProjectSection EndProjectSection
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{815C0625-CD3D-440F-9F80-2D83856AB7AE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{56801022-D71A-4FBE-BC5B-CBA08E2284EC}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ImageProcessorCore.Benchmarks", "tests\ImageProcessorCore.Benchmarks\ImageProcessorCore.Benchmarks.xproj", "{299D8E18-102C-42DE-ADBF-79098EE706A8}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -26,8 +32,17 @@ Global
{F836E8E6-B4D9-4208-8346-140C74678B91}.Debug|Any CPU.Build.0 = Debug|Any CPU {F836E8E6-B4D9-4208-8346-140C74678B91}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F836E8E6-B4D9-4208-8346-140C74678B91}.Release|Any CPU.ActiveCfg = Release|Any CPU {F836E8E6-B4D9-4208-8346-140C74678B91}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F836E8E6-B4D9-4208-8346-140C74678B91}.Release|Any CPU.Build.0 = Release|Any CPU {F836E8E6-B4D9-4208-8346-140C74678B91}.Release|Any CPU.Build.0 = Release|Any CPU
{299D8E18-102C-42DE-ADBF-79098EE706A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{299D8E18-102C-42DE-ADBF-79098EE706A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{299D8E18-102C-42DE-ADBF-79098EE706A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{299D8E18-102C-42DE-ADBF-79098EE706A8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{2AA31A1F-142C-43F4-8687-09ABCA4B3A26} = {815C0625-CD3D-440F-9F80-2D83856AB7AE}
{F836E8E6-B4D9-4208-8346-140C74678B91} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC}
{299D8E18-102C-42DE-ADBF-79098EE706A8} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC}
EndGlobalSection
EndGlobal EndGlobal

1
src/ImageProcessorCore/Properties/AssemblyInfo.cs

@ -30,4 +30,5 @@ using System.Runtime.InteropServices;
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
// Ensure the internals can be tested. // Ensure the internals can be tested.
[assembly: InternalsVisibleTo("ImageProcessorCore.Benchmarks")]
[assembly: InternalsVisibleTo("ImageProcessorCore.Tests")] [assembly: InternalsVisibleTo("ImageProcessorCore.Tests")]

9
src/ImageProcessorCore/project.json

@ -27,6 +27,11 @@
"Microsoft.NETCore.Platforms": "1.0.1-beta-23516" "Microsoft.NETCore.Platforms": "1.0.1-beta-23516"
}, },
"frameworks": { "frameworks": {
"dotnet5.5": { } "dotnet5.5": { },
"dnx46": {
"frameworkAssemblies": {
"System.Runtime": "4.0.0.0"
}
}
} }
} }

20
tests/ImageProcessorCore.Benchmarks/ImageProcessorCore.Benchmarks.xproj

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>299d8e18-102c-42de-adbf-79098ee706a8</ProjectGuid>
<RootNamespace>ImageProcessorCore.Benchmarks</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

26
tests/ImageProcessorCore.Benchmarks/Program.cs

@ -0,0 +1,26 @@
namespace ImageProcessorCore.Benchmarks
{
using System;
using System.Reflection;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Linq;
public class Program
{
public static void Main(string[] args)
{
//Use reflection for a more maintainable way of creating the benchmark switcher,
Type[] benchmarks = typeof(Program).Assembly.GetTypes()
.Where(t => t.GetMethods(BindingFlags.Instance | BindingFlags.Public)
.Any(m => m.GetCustomAttributes(typeof(BenchmarkAttribute), false).Any()))
.OrderBy(t => t.Namespace)
.ThenBy(t => t.Name)
.ToArray();
BenchmarkSwitcher benchmarkSwitcher = new BenchmarkSwitcher(benchmarks);
benchmarkSwitcher.Run(args);
}
}
}

23
tests/ImageProcessorCore.Benchmarks/Properties/AssemblyInfo.cs

@ -0,0 +1,23 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ImageProcessorCore.Benchmarks")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ImageProcessorCore.Benchmarks")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("299d8e18-102c-42de-adbf-79098ee706a8")]

44
tests/ImageProcessorCore.Benchmarks/Resize.cs

@ -0,0 +1,44 @@
namespace ImageProcessorCore.Benchmarks
{
using System.Drawing;
using System.Drawing.Drawing2D;
using BenchmarkDotNet.Attributes;
using ImageProcessorCore.Samplers;
using CoreImage = ImageProcessorCore.Image;
using CoreSize = ImageProcessorCore.Size;
public class Resize
{
[Benchmark(Baseline = true, Description = "System Drawing Resize")]
public Size ResizeSystemDrawing()
{
using (Bitmap source = new Bitmap(400, 400))
{
using (Bitmap destination = new Bitmap(100, 100))
{
using (Graphics graphics = Graphics.FromImage(destination))
{
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.DrawImage(source, 0, 0, 100, 100);
}
return destination.Size;
}
}
}
[Benchmark(Description = "ImageProcessor.Core Resize")]
public CoreSize ResizeCore()
{
using (CoreImage image = new CoreImage(400, 400))
{
image.Resize(100, 100);
return new CoreSize(image.Width, image.Height);
}
}
}
}

29
tests/ImageProcessorCore.Benchmarks/project.json

@ -0,0 +1,29 @@
{
"version": "1.0.0-*",
"description": "ImageProcessorCore.Benchmarks Console Application",
"authors": [ "James.South" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"ImageProcessorCore": "1.0.0-*",
"BenchmarkDotNet": "0.9.5"
},
"commands": {
"ImageProcessorCore.Benchmarks": "ImageProcessorCore.Benchmarks"
},
"frameworks": {
"dnx46": {
"frameworkAssemblies": {
"System.Drawing": "4.0.0.0"
}
}
}
}
Loading…
Cancel
Save