Skip to content
Merged
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
71 changes: 71 additions & 0 deletions tools/UglyToad.PdfPig.Benchmarks/BruteForceBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
Binary file not shown.
2 changes: 1 addition & 1 deletion tools/UglyToad.PdfPig.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ internal class Program
{
static void Main(string[] args)
{
var summary = BenchmarkRunner.Run<LayoutAnalysisBenchmarks>();
var summary = BenchmarkRunner.Run<BruteForceBenchmarks>();
Console.ReadKey();
}
}
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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>
10 changes: 8 additions & 2 deletions tools/UglyToad.PdfPig.Benchmarks/UglyToad.PdfPig.Benchmarks.slnx
Original file line number Diff line number Diff line change
@@ -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>
Binary file added tools/UglyToad.PdfPig.Benchmarks/algo.pdf
Binary file not shown.
Loading