Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
43cbdab
Fix stylecop warnings in the test project
brianpopow Jan 21, 2020
38454f8
Use using declarations to reduce nesting
brianpopow Jan 22, 2020
bb42df5
Merge remote-tracking branch 'upstream/master' into feature/stylecopT…
brianpopow Jan 22, 2020
6c40593
Remove regions
brianpopow Jan 23, 2020
f897ab6
Change WithTestPatternImageAttribute to WithTestPatternImagesAttribute
brianpopow Jan 23, 2020
94dc54b
Rename method names again to be the same as in the reference implemen…
brianpopow Jan 23, 2020
715de4c
Defining the tmp vars in a single line again
brianpopow Jan 23, 2020
8a6797c
Move ITestImageProvider to a separate file
brianpopow Jan 23, 2020
d59ca98
Revert comment as it was before, add exception for SA1115
brianpopow Jan 23, 2020
32bc422
Merge remote-tracking branch 'upstream/master' into feature/stylecopT…
brianpopow Jan 30, 2020
076a2bc
Update external for the changed test ruleset
brianpopow Jan 30, 2020
6f0e6e9
Fix some leftover stylecop warnings
brianpopow Jan 30, 2020
9f181a3
Change InternalsVisibleTo from SixLabors.ImageSharp.Sandbox46 to Imag…
brianpopow Jan 30, 2020
5ff7bb7
Revert "Change InternalsVisibleTo from SixLabors.ImageSharp.Sandbox46…
brianpopow Jan 31, 2020
0bce7af
Remove including tests into the profiling sandbox
brianpopow Jan 31, 2020
2c7e253
Merge branch 'master' into feature/stylecopTests
brianpopow Jan 31, 2020
15a7a55
Revert `using` declaration changes for until we establish guidelines.
JimBobSquarePants Feb 2, 2020
1f3311b
Add more rule exemptions and prevent blanket using recommendations
JimBobSquarePants Feb 2, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 1 addition & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Net.Compilers.Toolset" IsImplicitlyDefined="true" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" IsImplicitlyDefined="true" />
<!--TODO: Enable this once tests Stylecop issues are fixed-->
<!--<PackageReference Include="StyleCop.Analyzers" IsImplicitlyDefined="true" />-->
<PackageReference Include="StyleCop.Analyzers" IsImplicitlyDefined="true" />
<AdditionalFiles Include="$(MSBuildThisFileDirectory)shared-infrastructure\stylecop.json" />
<!--NuGet package icon source-->
<None Include="$(MSBuildThisFileDirectory)shared-infrastructure\branding\icons\imagesharp\sixlabors.imagesharp.128.png" Pack="true" PackagePath="\icon.png" />
Expand Down
3 changes: 0 additions & 3 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
</PropertyGroup>

<ItemGroup>
<!--TODO: Delete this once tests Stylecop issues are fixed-->
<PackageReference Include="StyleCop.Analyzers" IsImplicitlyDefined="true" />

<InternalsVisibleTo Include="DynamicProxyGenAssembly2" PublicKey="0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7" />
<InternalsVisibleTo Include="DynamicProxyGenAssembly2, PublicKeyToken=null" />
<InternalsVisibleTo Include="ImageSharp.Benchmarks" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public IccChromaticityTagDataEntry ReadChromaticityTagDataEntry()
else
{
// The type is not know, so the values need be read
var values = new double[channelCount][];
double[][] values = new double[channelCount][];
for (int i = 0; i < channelCount; i++)
{
values[i] = new double[] { this.ReadUFix16(), this.ReadUFix16() };
Expand Down Expand Up @@ -208,7 +208,7 @@ public IccCurveTagDataEntry ReadCurveTagDataEntry()
return new IccCurveTagDataEntry(this.ReadUFix8());
}

var cdata = new float[pointCount];
float[] cdata = new float[pointCount];
for (int i = 0; i < pointCount; i++)
{
cdata[i] = this.ReadUInt16() / 65535f;
Expand Down Expand Up @@ -264,7 +264,7 @@ public IccLut16TagDataEntry ReadLut16TagDataEntry()

// Input LUT
var inValues = new IccLut[inChCount];
var gridPointCount = new byte[inChCount];
byte[] gridPointCount = new byte[inChCount];
for (int i = 0; i < inChCount; i++)
{
inValues[i] = this.ReadLut16(inTableCount);
Expand Down Expand Up @@ -299,7 +299,7 @@ public IccLut8TagDataEntry ReadLut8TagDataEntry()

// Input LUT
var inValues = new IccLut[inChCount];
var gridPointCount = new byte[inChCount];
byte[] gridPointCount = new byte[inChCount];
for (int i = 0; i < inChCount; i++)
{
inValues[i] = this.ReadLut8();
Expand Down Expand Up @@ -464,8 +464,8 @@ public IccMultiLocalizedUnicodeTagDataEntry ReadMultiLocalizedUnicodeTagDataEntr
var text = new IccLocalizedString[recordCount];

var culture = new CultureInfo[recordCount];
var length = new uint[recordCount];
var offset = new uint[recordCount];
uint[] length = new uint[recordCount];
uint[] offset = new uint[recordCount];

for (int i = 0; i < recordCount; i++)
{
Expand Down Expand Up @@ -627,7 +627,7 @@ public IccResponseCurveSet16TagDataEntry ReadResponseCurveSet16TagDataEntry()
ushort channelCount = this.ReadUInt16();
ushort measurementCount = this.ReadUInt16();

var offset = new uint[measurementCount];
uint[] offset = new uint[measurementCount];
for (int i = 0; i < measurementCount; i++)
{
offset[i] = this.ReadUInt32();
Expand All @@ -651,7 +651,7 @@ public IccResponseCurveSet16TagDataEntry ReadResponseCurveSet16TagDataEntry()
public IccFix16ArrayTagDataEntry ReadFix16ArrayTagDataEntry(uint size)
{
uint count = (size - 8) / 4;
var arrayData = new float[count];
float[] arrayData = new float[count];
for (int i = 0; i < count; i++)
{
arrayData[i] = this.ReadFix16() / 256f;
Expand Down Expand Up @@ -687,7 +687,7 @@ public IccTextTagDataEntry ReadTextTagDataEntry(uint size)
public IccUFix16ArrayTagDataEntry ReadUFix16ArrayTagDataEntry(uint size)
{
uint count = (size - 8) / 4;
var arrayData = new float[count];
float[] arrayData = new float[count];
for (int i = 0; i < count; i++)
{
arrayData[i] = this.ReadUFix16();
Expand All @@ -704,7 +704,7 @@ public IccUFix16ArrayTagDataEntry ReadUFix16ArrayTagDataEntry(uint size)
public IccUInt16ArrayTagDataEntry ReadUInt16ArrayTagDataEntry(uint size)
{
uint count = (size - 8) / 2;
var arrayData = new ushort[count];
ushort[] arrayData = new ushort[count];
for (int i = 0; i < count; i++)
{
arrayData[i] = this.ReadUInt16();
Expand All @@ -721,7 +721,7 @@ public IccUInt16ArrayTagDataEntry ReadUInt16ArrayTagDataEntry(uint size)
public IccUInt32ArrayTagDataEntry ReadUInt32ArrayTagDataEntry(uint size)
{
uint count = (size - 8) / 4;
var arrayData = new uint[count];
uint[] arrayData = new uint[count];
for (int i = 0; i < count; i++)
{
arrayData[i] = this.ReadUInt32();
Expand All @@ -738,7 +738,7 @@ public IccUInt32ArrayTagDataEntry ReadUInt32ArrayTagDataEntry(uint size)
public IccUInt64ArrayTagDataEntry ReadUInt64ArrayTagDataEntry(uint size)
{
uint count = (size - 8) / 8;
var arrayData = new ulong[count];
ulong[] arrayData = new ulong[count];
for (int i = 0; i < count; i++)
{
arrayData[i] = this.ReadUInt64();
Expand Down Expand Up @@ -878,14 +878,14 @@ public IccScreeningTagDataEntry ReadScreeningTagDataEntry()
public IccUcrBgTagDataEntry ReadUcrBgTagDataEntry(uint size)
{
uint ucrCount = this.ReadUInt32();
var ucrCurve = new ushort[ucrCount];
ushort[] ucrCurve = new ushort[ucrCount];
for (int i = 0; i < ucrCurve.Length; i++)
{
ucrCurve[i] = this.ReadUInt16();
}

uint bgCount = this.ReadUInt32();
var bgCurve = new ushort[bgCount];
ushort[] bgCurve = new ushort[bgCount];
for (int i = 0; i < bgCurve.Length; i++)
{
bgCurve[i] = this.ReadUInt16();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down
23 changes: 13 additions & 10 deletions tests/ImageSharp.Benchmarks/Codecs/DecodeTga.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
public class DecodeTga : BenchmarkBase
{
private string TestImageFullPath => Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, this.TestImage);

private readonly PfimConfig pfimConfig = new PfimConfig(allocator: new PfimAllocator());

private byte[] data;

[Params(TestImages.Tga.Bit24)]
Expand Down Expand Up @@ -77,15 +79,16 @@ public void Return(byte[] data)
public int Rented => this.rented;
}

// RESULTS (07/01/2020)
//| Method | Runtime | TestImage | Mean | Error | StdDev | Ratio | Gen 0 | Gen 1 | Gen 2 | Allocated |
//|------------------ |-------------- |-------------------- |-------------:|-------------:|-----------:|------:|-------:|------:|------:|----------:|
//| 'ImageMagick Tga' | .NET 4.7.2 | Tga/targa_24bit.tga | 1,778.965 us | 1,711.088 us | 93.7905 us | 1.000 | 1.9531 | - | - | 13668 B |
//| 'ImageSharp Tga' | .NET 4.7.2 | Tga/targa_24bit.tga | 38.659 us | 6.886 us | 0.3774 us | 0.022 | 0.3052 | - | - | 1316 B |
//| 'Pfim Tga' | .NET 4.7.2 | Tga/targa_24bit.tga | 6.752 us | 10.268 us | 0.5628 us | 0.004 | 0.0687 | - | - | 313 B |
//| | | | | | | | | | | |
//| 'ImageMagick Tga' | .NET Core 2.1 | Tga/targa_24bit.tga | 1,407.585 us | 124.215 us | 6.8087 us | 1.000 | 1.9531 | - | - | 13307 B |
//| 'ImageSharp Tga' | .NET Core 2.1 | Tga/targa_24bit.tga | 17.958 us | 9.352 us | 0.5126 us | 0.013 | 0.2747 | - | - | 1256 B |
//| 'Pfim Tga' | .NET Core 2.1 | Tga/targa_24bit.tga | 5.645 us | 2.279 us | 0.1249 us | 0.004 | 0.0610 | - | - | 280 B |
/* RESULTS (07/01/2020)
| Method | Runtime | TestImage | Mean | Error | StdDev | Ratio | Gen 0 | Gen 1 | Gen 2 | Allocated |
|------------------ |-------------- |-------------------- |-------------:|-------------:|-----------:|------:|-------:|------:|------:|----------:|
| 'ImageMagick Tga' | .NET 4.7.2 | Tga/targa_24bit.tga | 1,778.965 us | 1,711.088 us | 93.7905 us | 1.000 | 1.9531 | - | - | 13668 B |
| 'ImageSharp Tga' | .NET 4.7.2 | Tga/targa_24bit.tga | 38.659 us | 6.886 us | 0.3774 us | 0.022 | 0.3052 | - | - | 1316 B |
| 'Pfim Tga' | .NET 4.7.2 | Tga/targa_24bit.tga | 6.752 us | 10.268 us | 0.5628 us | 0.004 | 0.0687 | - | - | 313 B |
| | | | | | | | | | | |
| 'ImageMagick Tga' | .NET Core 2.1 | Tga/targa_24bit.tga | 1,407.585 us | 124.215 us | 6.8087 us | 1.000 | 1.9531 | - | - | 13307 B |
| 'ImageSharp Tga' | .NET Core 2.1 | Tga/targa_24bit.tga | 17.958 us | 9.352 us | 0.5126 us | 0.013 | 0.2747 | - | - | 1256 B |
| 'Pfim Tga' | .NET Core 2.1 | Tga/targa_24bit.tga | 5.645 us | 2.279 us | 0.1249 us | 0.004 | 0.0610 | - | - | 280 B |
*/
}
}
16 changes: 12 additions & 4 deletions tests/ImageSharp.Benchmarks/Codecs/EncodeBmpMultiple.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System.Collections.Generic;
Expand All @@ -16,13 +16,21 @@ public class EncodeBmpMultiple : MultiImageBenchmarkBase.WithImagesPreloaded
[Benchmark(Description = "EncodeBmpMultiple - ImageSharp")]
public void EncodeBmpImageSharp()
{
this.ForEachImageSharpImage((img, ms) => { img.Save(ms, new BmpEncoder()); return null; });
this.ForEachImageSharpImage((img, ms) =>
{
img.Save(ms, new BmpEncoder());
return null;
});
}

[Benchmark(Baseline = true, Description = "EncodeBmpMultiple - System.Drawing")]
public void EncodeBmpSystemDrawing()
{
this.ForEachSystemDrawingImage((img, ms) => { img.Save(ms, ImageFormat.Bmp); return null; });
this.ForEachSystemDrawingImage((img, ms) =>
{
img.Save(ms, ImageFormat.Bmp);
return null;
});
}
}
}
}
13 changes: 9 additions & 4 deletions tests/ImageSharp.Benchmarks/Codecs/EncodeGifMultiple.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System.Collections.Generic;
Expand All @@ -24,14 +24,19 @@ public void EncodeGifImageSharp()
{
// Try to get as close to System.Drawing's output as possible
var options = new GifEncoder { Quantizer = new WebSafePaletteQuantizer(false) };
img.Save(ms, options); return null;
img.Save(ms, options);
return null;
});
}

[Benchmark(Baseline = true, Description = "EncodeGifMultiple - System.Drawing")]
public void EncodeGifSystemDrawing()
{
this.ForEachSystemDrawingImage((img, ms) => { img.Save(ms, ImageFormat.Gif); return null; });
this.ForEachSystemDrawingImage((img, ms) =>
{
img.Save(ms, ImageFormat.Gif);
return null;
});
}
}
}
}
2 changes: 1 addition & 1 deletion tests/ImageSharp.Benchmarks/Codecs/EncodeTga.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void ReadImages()
{
if (this.tgaCore == null)
{
this.tgaCore = Image.Load<Rgba32>(TestImageFullPath);
this.tgaCore = Image.Load<Rgba32>(this.TestImageFullPath);
this.tgaMagick = new MagickImage(this.TestImageFullPath);
}
}
Expand Down
5 changes: 2 additions & 3 deletions tests/ImageSharp.Benchmarks/Codecs/ImageBenchmarkTests.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

// This file contains small, cheap and "unit test" benchmarks to test MultiImageBenchmarkBase.
// Need this because there are no real test cases for the common benchmark utility stuff.

// Uncomment this to enable benchmark testing
// #define TEST

#if TEST

// ReSharper disable InconsistentNaming
Expand Down Expand Up @@ -76,4 +75,4 @@ public void Run()
}
}

#endif
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand All @@ -9,8 +9,8 @@

using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.Memory;
// ReSharper disable InconsistentNaming

// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations
{
public class Block8x8F_CopyTo1x1
Expand Down Expand Up @@ -130,4 +130,4 @@ public void UseVector8_V2()
// Conclusion:
// Doesn't worth to bother with this
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System.Numerics;
Expand All @@ -8,8 +8,8 @@

using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.Memory;
// ReSharper disable InconsistentNaming

// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations
{
public class Block8x8F_CopyTo2x2
Expand Down Expand Up @@ -335,7 +335,6 @@ private static void WidenCopyImpl2x2_Vector4_SafeRightCorner(ref Block8x8F src,
Unsafe.Add(ref dBottomLeft, 7) = wRight;
}


[Benchmark]
public void UseVector4_V2()
{
Expand Down Expand Up @@ -409,4 +408,4 @@ private static void WidenCopyImpl2x2_Vector4_V2(ref Block8x8F src, ref Vector2 d
// UseVector4_SafeRightCorner | 58.97 ns | 0.4152 ns | 0.3884 ns | 0.64 | 0.02 |
// UseVector4_V2 | 41.88 ns | 0.3531 ns | 0.3303 ns | 0.45 | 0.01 |
}
}
}
Loading