Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions GpkgMerger.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MergerService", "MergerService\MergerService.csproj", "{000F75C1-01FD-423F-94CD-6F24C5C31A3B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MergerLogicUnitTests", "MergerLogicUnitTests\MergerLogicUnitTests.csproj", "{29DADE7E-10F0-4AD0-9EAE-CF0387E3F1F1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MergerLogicUnitTests", "MergerLogicUnitTests\MergerLogicUnitTests.csproj", "{29DADE7E-10F0-4AD0-9EAE-CF0387E3F1F1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MergerServiceUnitTests", "MergerServiceUnitTests\MergerServiceUnitTests.csproj", "{1E0BF0FA-12E2-4CEA-99C7-1AB692494795}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MergerServiceUnitTests", "MergerServiceUnitTests\MergerServiceUnitTests.csproj", "{1E0BF0FA-12E2-4CEA-99C7-1AB692494795}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MergerLogicBanchmarkTests", "MergerLogicBanchmarkTests\MergerLogicBanchmarkTests.csproj", "{FD89E1F2-7C6E-42E0-96E5-2D7D1D567836}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -47,6 +49,10 @@ Global
{1E0BF0FA-12E2-4CEA-99C7-1AB692494795}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1E0BF0FA-12E2-4CEA-99C7-1AB692494795}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1E0BF0FA-12E2-4CEA-99C7-1AB692494795}.Release|Any CPU.Build.0 = Release|Any CPU
{FD89E1F2-7C6E-42E0-96E5-2D7D1D567836}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{FD89E1F2-7C6E-42E0-96E5-2D7D1D567836}.Debug|Any CPU.Build.0 = Release|Any CPU
{FD89E1F2-7C6E-42E0-96E5-2D7D1D567836}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FD89E1F2-7C6E-42E0-96E5-2D7D1D567836}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
73 changes: 73 additions & 0 deletions MergerLogicBanchmarkTests/MergeTilesBenchmarkTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using BenchmarkDotNet.Attributes;
using MergerLogic.Batching;
using MergerLogic.DataTypes;
using MergerLogic.ImageProcessing;
using MergerLogic.Monitoring.Metrics;
using Microsoft.Extensions.Logging;
using Moq;
using static MergerLogic.ImageProcessing.TileFormatStrategy;

namespace MergerLogicBanchmarkTests
{
public class MergeTilesBenchmarkTest
{
#region mocks

private MockRepository _mockRepository;
private TileMerger _testTileMerger;
private Coord targetCoordLowZoom;
private List<CorrespondingTileBuilder> tileBuilderList;
private TileFormatStrategy tileFormatStrategy;

Tile testTilePNG1;
Tile testTilePNG2;

#endregion

[GlobalSetup]
public void GlobalSetup()
{
//Write your initialization code here
}

[ParamsAllValues]
public FormatStrategy Strategy { get; set; }

[ParamsAllValues]
public TileFormat Format { get; set; }

[Params(true, false)]
public bool UploadOnly { get; set; }

public MergeTilesBenchmarkTest()
{
this._mockRepository = new MockRepository(MockBehavior.Loose);

var metricsProviderMock = this._mockRepository.Create<IMetricsProvider>();
var tileScalerLoggerMock = this._mockRepository.Create<ILogger<TileScaler>>();
var tileMergerLoggerMock = this._mockRepository.Create<ILogger<TileMerger>>();

var testTileScaler = new TileScaler(metricsProviderMock.Object, tileScalerLoggerMock.Object);
this._testTileMerger = new TileMerger(testTileScaler, tileMergerLoggerMock.Object);

targetCoordLowZoom = new Coord(5, 0, 0);

testTilePNG1 = new Tile(targetCoordLowZoom, File.ReadAllBytes(Path.Combine(".\\", "TestImages", "2.png")));
testTilePNG2 = new Tile(targetCoordLowZoom, File.ReadAllBytes(Path.Combine(".\\", "TestImages", "1.png")));


tileBuilderList = new List<CorrespondingTileBuilder>()
{
() => testTilePNG1, () => testTilePNG2
};
}

[Benchmark]
public void MergeTiles_Benchmark()
{
tileFormatStrategy = new TileFormatStrategy(this.Format, this.Strategy);
//Write your code here
var result = this._testTileMerger.MergeTiles(tileBuilderList, targetCoordLowZoom, tileFormatStrategy, this.UploadOnly);
}
}
}
34 changes: 34 additions & 0 deletions MergerLogicBanchmarkTests/MergerLogicBanchmarkTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="Moq" Version="4.20.70" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\MergerLogic\MergerLogic.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="TestImages\1.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestImages\2.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestImages\5.jpeg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestImages\5_64bit.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
23 changes: 23 additions & 0 deletions MergerLogicBanchmarkTests/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using MergerLogic.Batching;
using MergerLogic.DataTypes;
using MergerLogic.ImageProcessing;
using MergerLogic.Monitoring.Metrics;
using MergerLogicBanchmarkTests;
using Microsoft.Extensions.Logging;
using Moq;
using static MergerLogic.ImageProcessing.TileFormatStrategy;

namespace MergerLogicBenchmarksTests
{
public class Program
{
public static void Main(string[] args)
{
var summary = BenchmarkRunner.Run<UpscaleBenchmarkTest>();
// var summary2 = BenchmarkRunner.Run<MergeTilesBenchmarkTest>();
}
}
}

Binary file added MergerLogicBanchmarkTests/TestImages/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MergerLogicBanchmarkTests/TestImages/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MergerLogicBanchmarkTests/TestImages/5.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MergerLogicBanchmarkTests/TestImages/5_64bit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions MergerLogicBanchmarkTests/UpscaleBenchmarkTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using BenchmarkDotNet.Attributes;
using MergerLogic.Batching;
using MergerLogic.DataTypes;
using MergerLogic.ImageProcessing;
using MergerLogic.Monitoring.Metrics;
using Microsoft.Extensions.Logging;
using Moq;

namespace MergerLogicBanchmarkTests
{
public class UpscaleBenchmarkTest
{
#region mocks

private MockRepository _mockRepository;

private TileScaler _testTileScaler;

private Tile testTileJpeg;
private Tile testTilePNG;

#endregion

[GlobalSetup]
public void GlobalSetup()
{
//Write your initialization code here
}

public UpscaleBenchmarkTest()
{
testTileJpeg = new Tile(new Coord(3, 0, 0), System.IO.File.ReadAllBytes(Path.Combine(".\\", "TestImages", "5.jpeg")));
testTilePNG = new Tile(new Coord(3, 0, 0), System.IO.File.ReadAllBytes(Path.Combine(".\\", "TestImages", "5_64bit.png")));

this._mockRepository = new MockRepository(MockBehavior.Loose);

var metricsProviderMock = this._mockRepository.Create<IMetricsProvider>();
var tileScalerLoggerMock = this._mockRepository.Create<ILogger<TileScaler>>();

this._testTileScaler = new TileScaler(metricsProviderMock.Object, tileScalerLoggerMock.Object);
}

[Benchmark]
public void Upscale_jpeg()
{
//Write your code here
var resultTile = this._testTileScaler.Upscale(testTileJpeg, new Coord(4, 0, 0));
}
[Benchmark]
public void Upscale_png()
{
//Write your code here
var resultTile = this._testTileScaler.Upscale(testTilePNG, new Coord(4, 0, 0));
}
}
}