Browse Source

JpegBenchmark

pull/34/head
Anton Firszov 9 years ago
parent
commit
d90b6e5b95
  1. 14
      ImageSharp.sln
  2. 15
      src/ImageSharp46/Formats/Jpg/Components/Block8x8F.cs
  3. 21
      tests/JpegBenchmark/JpegBenchmark.xproj
  4. 65
      tests/JpegBenchmark/Program.cs
  5. 19
      tests/JpegBenchmark/Properties/AssemblyInfo.cs
  6. 21
      tests/JpegBenchmark/project.json

14
ImageSharp.sln

@ -7,8 +7,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ImageSharp", "src\ImageShar
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ImageSharp.Tests", "tests\ImageSharp.Tests\ImageSharp.Tests.xproj", "{F836E8E6-B4D9-4208-8346-140C74678B91}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ImageSharp.Benchmarks", "tests\ImageSharp.Benchmarks\ImageSharp.Benchmarks.xproj", "{299D8E18-102C-42DE-ADBF-79098EE706A8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{C317F1B1-D75E-4C6D-83EB-80367343E0D7}"
ProjectSection(SolutionItems) = preProject
build\appveyor-project-version-patch.js = build\appveyor-project-version-patch.js
@ -25,6 +23,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{815C06
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{56801022-D71A-4FBE-BC5B-CBA08E2284EC}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "JpegBenchmark", "tests\JpegBenchmark\JpegBenchmark.xproj", "{7C69F09A-3286-45A1-BED2-B9C628150FA9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -39,10 +39,10 @@ Global
{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.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
{7C69F09A-3286-45A1-BED2-B9C628150FA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C69F09A-3286-45A1-BED2-B9C628150FA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C69F09A-3286-45A1-BED2-B9C628150FA9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7C69F09A-3286-45A1-BED2-B9C628150FA9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -50,6 +50,6 @@ Global
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}
{7C69F09A-3286-45A1-BED2-B9C628150FA9} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC}
EndGlobalSection
EndGlobal

15
src/ImageSharp46/Formats/Jpg/Components/Block8x8F.cs

@ -491,6 +491,19 @@ namespace ImageSharp.Formats
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static unsafe void UnZig(Block8x8F* block, Block8x8F* qt, int* unzigPtr)
{
float* b = (float*)block;
float* qtp = (float*)qt;
for (int zig = 0; zig < BlockF.BlockSize; zig++)
{
float* unzigPos = b + unzigPtr[zig];
float val = *unzigPos;
val *= qtp[zig];
*unzigPos = val;
}
}
}
}

21
tests/JpegBenchmark/JpegBenchmark.xproj

@ -0,0 +1,21 @@
<?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)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>7c69f09a-3286-45a1-bed2-b9c628150fa9</ProjectGuid>
<RootNamespace>JpegBenchmark</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

65
tests/JpegBenchmark/Program.cs

@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Reflection;
using System.Threading.Tasks;
using ImageSharp;
namespace JpegBenchmark
{
public class Program
{
private const string TestImageDir = @"../ImageSharp.Tests/TestImages/Formats/Jpg";
private static byte[][] ReadAllFiles()
{
var files = Directory.EnumerateFiles(TestImageDir).ToArray();
return files.Select(File.ReadAllBytes).ToArray();
}
public static void Main(string[] args)
{
var allData = ReadAllFiles();
int times;
if (args.Length == 0 || !int.TryParse(args[0], out times))
{
times = 20;
}
Console.WriteLine($"Vector.IsHardwareAccelerated == {Vector.IsHardwareAccelerated}");
Console.WriteLine($"Decoding {allData.Length} jpegs X {times} times ...");
double estimatedTotalBlockCount = 0;
Stopwatch sw = Stopwatch.StartNew();
for (int i = 0; i < times; i++)
{
estimatedTotalBlockCount = DecodeAll(allData);
}
sw.Stop();
Console.WriteLine($"Completed in {sw.ElapsedMilliseconds} ms");
Console.WriteLine($"Estimated block count: {estimatedTotalBlockCount}");
Console.ReadLine();
}
private static double DecodeAll(byte[][] allData)
{
double estimatedTotalBlockCount = 0;
foreach (byte[] data in allData)
{
var stream = new MemoryStream(data);
Image img = new Image(stream);
estimatedTotalBlockCount += img.Width*img.Height/64.0;
}
return estimatedTotalBlockCount;
}
}
}

19
tests/JpegBenchmark/Properties/AssemblyInfo.cs

@ -0,0 +1,19 @@
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: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Sapa")]
[assembly: AssemblyProduct("JpegBenchmark")]
[assembly: AssemblyTrademark("")]
// 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("7c69f09a-3286-45a1-bed2-b9c628150fa9")]

21
tests/JpegBenchmark/project.json

@ -0,0 +1,21 @@
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true,
"optimize": true
},
"dependencies": {
"ImageSharp": "1.0.0-*",
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50"
}
}
}
Loading…
Cancel
Save