Welcome to mirror list, hosted at ThFree Co, Russian Federation.

NesTiler.git/NesTiler.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2022-10-13 18:26:31 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2022-10-13 18:26:31 +0300
commita42bc5d174398a23039e99521da61e505c1a8482 (patch)
treeffc06ae8f3bf59865d9a70cc458005f8cf55ff89 /Benchmarks
parent610332bc0ff089224747cf35bdb51cefc4e29eac (diff)
Tests
Diffstat (limited to 'Benchmarks')
-rw-r--r--Benchmarks/Benchmarks.csproj71
-rw-r--r--Benchmarks/Program.cs163
2 files changed, 234 insertions, 0 deletions
diff --git a/Benchmarks/Benchmarks.csproj b/Benchmarks/Benchmarks.csproj
new file mode 100644
index 0000000..0bc461e
--- /dev/null
+++ b/Benchmarks/Benchmarks.csproj
@@ -0,0 +1,71 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <OutputType>Exe</OutputType>
+ <TargetFramework>net6.0</TargetFramework>
+ <ImplicitUsings>enable</ImplicitUsings>
+ <Nullable>enable</Nullable>
+ <StartupObject></StartupObject>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\NesTiler\NesTiler.csproj" />
+ <ProjectReference Include="..\TestImages\TestImages.csproj" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Update="Images\belaya_akula.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Update="..\Images\buhanka.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Update="..\Images\chernobyl.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Update="..\Images\dira.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Update="..\Images\glaza.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Update="..\Images\gorgona.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Update="..\Images\myatej.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Update="..\Images\pagoda.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Update="..\Images\rayon4.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Update="..\Images\shkola.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Update="..\Images\sindikat.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Update="..\Images\sputnik.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Update="..\Images\sworm.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Update="..\Images\trailer-park.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Update="..\Images\warface_logo.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Update="..\Images\zapravka.gif">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ </ItemGroup>
+
+</Project>
diff --git a/Benchmarks/Program.cs b/Benchmarks/Program.cs
new file mode 100644
index 0000000..8392ed6
--- /dev/null
+++ b/Benchmarks/Program.cs
@@ -0,0 +1,163 @@
+using BenchmarkDotNet.Attributes;
+using BenchmarkDotNet.Running;
+
+namespace com.clusterrr.Famicom.NesTiler.Benchmarks
+{
+ public class Benchmarks
+ {
+ static void Main()
+ {
+ var summary = BenchmarkRunner.Run<Benchmarks>();
+ Console.WriteLine(summary);
+ }
+
+ [Benchmark]
+ public void BenchmarkBelayaAkula()
+ {
+ var imagePath = @"Images\belaya_akula.gif";
+ DoBenchmarkSplit4(imagePath);
+ }
+
+ [Benchmark]
+ public void BenchmarkBuhanka()
+ {
+ var imagePath = @"Images\buhanka.gif";
+ DoBenchmarkSplit4(imagePath);
+ }
+
+ [Benchmark]
+ public void BenchmarkChernobyl()
+ {
+ var imagePath = @"Images\chernobyl.gif";
+ DoBenchmarkSplit4(imagePath);
+ }
+
+ [Benchmark]
+ public void BenchmarkDira()
+ {
+ var imagePath = @"Images\dira.gif";
+ DoBenchmarkSplit4(imagePath);
+ }
+
+ [Benchmark]
+ public void BenchmarkGlaza()
+ {
+ var imagePath = @"Images\glaza.gif";
+ DoBenchmarkSplit4(imagePath);
+ }
+
+ [Benchmark]
+ public void BenchmarkGorgona()
+ {
+ var imagePath = @"Images\gorgona.gif";
+ DoBenchmarkSplit4(imagePath);
+ }
+
+ [Benchmark]
+ public void BenchmarkMyatejl()
+ {
+ var imagePath = @"Images\myatej.gif";
+ DoBenchmarkSplit4(imagePath);
+ }
+
+ [Benchmark]
+ public void BenchmarkPagoda()
+ {
+ var imagePath = @"Images\pagoda.gif";
+ DoBenchmarkSplit4(imagePath);
+ }
+
+ [Benchmark]
+ public void BenchmarkRayon4()
+ {
+ var imagePath = @"Images\rayon4.gif";
+ DoBenchmarkSplit4(imagePath);
+ }
+
+ [Benchmark]
+ public void BenchmarkShkola()
+ {
+ var imagePath = @"Images\shkola.gif";
+ DoBenchmarkSplit4(imagePath);
+ }
+
+ [Benchmark]
+ public void BenchmarkSindikat()
+ {
+ var imagePath = @"Images\sindikat.gif";
+ DoBenchmarkSplit4(imagePath);
+ }
+
+ [Benchmark]
+ public void BenchmarkSputnik()
+ {
+ var imagePath = @"Images\sputnik.gif";
+ DoBenchmarkSplit4(imagePath);
+ }
+
+ [Benchmark]
+ public void BenchmarkSworm()
+ {
+ var imagePath = @"Images\sworm.gif";
+ DoBenchmarkSplit4(imagePath);
+ }
+
+ [Benchmark]
+ public void BenchmarkTrailerPark()
+ {
+ var imagePath = @"Images\trailer-park.gif";
+ DoBenchmarkSplit4(imagePath);
+ }
+
+ [Benchmark]
+ public void BenchmarkWarfaceLogo()
+ {
+ var imagePath = @"Images\warface_logo.gif";
+ DoBenchmarkSplit4(imagePath);
+ }
+
+ [Benchmark]
+ public void BenchmarkZapravka()
+ {
+ var imagePath = @"Images\zapravka.gif";
+ DoBenchmarkSplit4(imagePath);
+ }
+
+ private string PatternTablePath(string prefix, int number) => $"{prefix}_pattern_{number}.bin";
+ private string NameTablePath(string prefix, int number) => $"{prefix}_name_table_{number}.bin";
+ private string AttrTablePath(string prefix, int number) => $"{prefix}_attr_table_{number}.bin";
+ private string PalettePath(string prefix, int number) => $"{prefix}_palette_{number}.bin";
+
+ public void DoBenchmarkSplit4(string imagePath)
+ {
+ var prefix = Path.GetFileNameWithoutExtension(imagePath);
+ var args = new string[] {
+ "--enable-palettes", "0,1,2,3",
+ "-i0", $"{imagePath}:0:64",
+ "-i1", $"{imagePath}:64:64",
+ "-i2", $"{imagePath}:128:64",
+ "-i3", $"{imagePath}:192:48",
+ "--out-pattern-table0", PatternTablePath(prefix, 0),
+ "--out-pattern-table1", PatternTablePath(prefix, 1),
+ "--out-pattern-table2", PatternTablePath(prefix, 2),
+ "--out-pattern-table3", PatternTablePath(prefix, 3),
+ "--out-name-table0", NameTablePath(prefix, 0),
+ "--out-name-table1", NameTablePath(prefix, 1),
+ "--out-name-table2", NameTablePath(prefix, 2),
+ "--out-name-table3", NameTablePath(prefix, 3),
+ "--out-attribute-table0", AttrTablePath(prefix, 0),
+ "--out-attribute-table1", AttrTablePath(prefix, 1),
+ "--out-attribute-table2", AttrTablePath(prefix, 2),
+ "--out-attribute-table3", AttrTablePath(prefix, 3),
+ "--out-palette0", PalettePath(prefix, 0),
+ "--out-palette1", PalettePath(prefix, 1),
+ "--out-palette2", PalettePath(prefix, 2),
+ "--out-palette3", PalettePath(prefix, 3),
+ };
+ var r = Program.Main(args);
+ if (r != 0) throw new InvalidOperationException($"Return code: {r}");
+
+ //foreach (var file in Directory.GetFiles(".", "*.bin")) File.Copy(file, Path.Join(@"E:\bins", Path.GetFileName(file)), true);
+ }
+ }
+} \ No newline at end of file