mirror of https://github.com/SixLabors/ImageSharp
6 changed files with 147 additions and 8 deletions
@ -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> |
|||
@ -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; |
|||
} |
|||
} |
|||
} |
|||
@ -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")] |
|||
@ -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…
Reference in new issue