Fix Benchmarks solution and add BruteForceBenchmarks

This commit is contained in:
BobLd
2026-02-22 16:33:25 +00:00
parent 9c0d6893e0
commit 34db05f735
8 changed files with 138818 additions and 4 deletions

View File

@@ -0,0 +1,71 @@
using BenchmarkDotNet.Attributes;
using UglyToad.PdfPig.Content;
namespace UglyToad.PdfPig.Benchmarks;
[Config(typeof(NuGetPackageConfig))]
[MemoryDiagnoser(displayGenColumns: false)]
public class BruteForceBenchmarks
{
[Benchmark]
public IReadOnlyList<Letter> OpenOffice()
{
List<Letter> letters = new List<Letter>();
using (var doc = PdfDocument.Open("Single Page Simple - from open office.pdf"))
{
foreach (var page in doc.GetPages())
{
letters.AddRange(page.Letters);
}
}
return letters;
}
[Benchmark]
public IReadOnlyList<Letter> Inkscape()
{
List<Letter> letters = new List<Letter>();
using (var doc = PdfDocument.Open("Single Page Simple - from inkscape.pdf"))
{
foreach (var page in doc.GetPages())
{
letters.AddRange(page.Letters);
}
}
return letters;
}
[Benchmark]
public IReadOnlyList<Letter> Algo()
{
List<Letter> letters = new List<Letter>();
using (var doc = PdfDocument.Open("algo.pdf"))
{
foreach (var page in doc.GetPages())
{
letters.AddRange(page.Letters);
}
}
return letters;
}
[Benchmark]
public IReadOnlyList<Letter> PDFBOX_492_4_jar_8()
{
List<Letter> letters = new List<Letter>();
using (var doc = PdfDocument.Open("PDFBOX-492-4.jar-8.pdf"))
{
foreach (var page in doc.GetPages())
{
letters.AddRange(page.Letters);
}
}
return letters;
}
}

View File

@@ -6,7 +6,7 @@ namespace UglyToad.PdfPig.Benchmarks
{
static void Main(string[] args)
{
var summary = BenchmarkRunner.Run<LayoutAnalysisBenchmarks>();
var summary = BenchmarkRunner.Run<BruteForceBenchmarks>();
Console.ReadKey();
}
}

View File

@@ -15,17 +15,33 @@
<ItemGroup Condition="'$(PdfPigVersion)' == 'Local'">
<ProjectReference Include="..\..\src\UglyToad.PdfPig\UglyToad.PdfPig.csproj" />
<ProjectReference Include="..\..\src\UglyToad.PdfPig.Core\UglyToad.PdfPig.Core.csproj" />
<ProjectReference Include="..\..\src\UglyToad.PdfPig.Fonts\UglyToad.PdfPig.Fonts.csproj" />
<ProjectReference Include="..\..\src\UglyToad.PdfPig.Tokenization\UglyToad.PdfPig.Tokenization.csproj" />
<ProjectReference Include="..\..\src\UglyToad.PdfPig.Tokens\UglyToad.PdfPig.Tokens.csproj" />
<ProjectReference Include="..\..\src\UglyToad.PdfPig.DocumentLayoutAnalysis\UglyToad.PdfPig.DocumentLayoutAnalysis.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(PdfPigVersion)' == 'Latest'">
<PackageReference Include="PdfPig" Version="0.1.14-alpha-20260216-7e370" />
<PackageReference Include="PdfPig" Version="0.1.14-alpha-20260219-adb57" />
</ItemGroup>
<ItemGroup>
<None Update="algo.pdf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="fseprd1102849.pdf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="PDFBOX-492-4.jar-8.pdf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Single Page Simple - from inkscape.pdf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Single Page Simple - from open office.pdf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@@ -1,6 +1,12 @@
<Solution>
<Folder Name="/PdfPig/">
<Project Path="../../src/UglyToad.PdfPig.Core/UglyToad.PdfPig.Core.csproj" />
<Project Path="../../src/UglyToad.PdfPig.DocumentLayoutAnalysis/UglyToad.PdfPig.DocumentLayoutAnalysis.csproj" />
<Project Path="../../src/UglyToad.PdfPig.Fonts/UglyToad.PdfPig.Fonts.csproj" />
<Project Path="../../src/UglyToad.PdfPig.Tokenization/UglyToad.PdfPig.Tokenization.csproj" />
<Project Path="../../src/UglyToad.PdfPig.Tokens/UglyToad.PdfPig.Tokens.csproj" />
<Project Path="../../src/UglyToad.PdfPig/UglyToad.PdfPig.csproj" />
</Folder>
<Folder Name="/Solution Items/" />
<Project Path="../../src/UglyToad.PdfPig.DocumentLayoutAnalysis/UglyToad.PdfPig.DocumentLayoutAnalysis.csproj" />
<Project Path="../../src/UglyToad.PdfPig/UglyToad.PdfPig.csproj" />
<Project Path="UglyToad.PdfPig.Benchmarks.csproj" />
</Solution>

File diff suppressed because one or more lines are too long