Skip to content

Commit 34db05f

Browse files
committed
Fix Benchmarks solution and add BruteForceBenchmarks
1 parent 9c0d689 commit 34db05f

File tree

8 files changed

+97
-4
lines changed

8 files changed

+97
-4
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
using BenchmarkDotNet.Attributes;
2+
using UglyToad.PdfPig.Content;
3+
4+
namespace UglyToad.PdfPig.Benchmarks;
5+
6+
[Config(typeof(NuGetPackageConfig))]
7+
[MemoryDiagnoser(displayGenColumns: false)]
8+
public class BruteForceBenchmarks
9+
{
10+
11+
[Benchmark]
12+
public IReadOnlyList<Letter> OpenOffice()
13+
{
14+
List<Letter> letters = new List<Letter>();
15+
using (var doc = PdfDocument.Open("Single Page Simple - from open office.pdf"))
16+
{
17+
foreach (var page in doc.GetPages())
18+
{
19+
letters.AddRange(page.Letters);
20+
}
21+
}
22+
23+
return letters;
24+
}
25+
26+
[Benchmark]
27+
public IReadOnlyList<Letter> Inkscape()
28+
{
29+
List<Letter> letters = new List<Letter>();
30+
using (var doc = PdfDocument.Open("Single Page Simple - from inkscape.pdf"))
31+
{
32+
foreach (var page in doc.GetPages())
33+
{
34+
letters.AddRange(page.Letters);
35+
}
36+
}
37+
38+
return letters;
39+
}
40+
41+
[Benchmark]
42+
public IReadOnlyList<Letter> Algo()
43+
{
44+
List<Letter> letters = new List<Letter>();
45+
using (var doc = PdfDocument.Open("algo.pdf"))
46+
{
47+
foreach (var page in doc.GetPages())
48+
{
49+
letters.AddRange(page.Letters);
50+
}
51+
}
52+
53+
return letters;
54+
}
55+
56+
57+
[Benchmark]
58+
public IReadOnlyList<Letter> PDFBOX_492_4_jar_8()
59+
{
60+
List<Letter> letters = new List<Letter>();
61+
using (var doc = PdfDocument.Open("PDFBOX-492-4.jar-8.pdf"))
62+
{
63+
foreach (var page in doc.GetPages())
64+
{
65+
letters.AddRange(page.Letters);
66+
}
67+
}
68+
69+
return letters;
70+
}
71+
}
279 KB
Binary file not shown.

tools/UglyToad.PdfPig.Benchmarks/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ internal class Program
66
{
77
static void Main(string[] args)
88
{
9-
var summary = BenchmarkRunner.Run<LayoutAnalysisBenchmarks>();
9+
var summary = BenchmarkRunner.Run<BruteForceBenchmarks>();
1010
Console.ReadKey();
1111
}
1212
}
Binary file not shown.
Binary file not shown.

tools/UglyToad.PdfPig.Benchmarks/UglyToad.PdfPig.Benchmarks.csproj

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,33 @@
1515

1616
<ItemGroup Condition="'$(PdfPigVersion)' == 'Local'">
1717
<ProjectReference Include="..\..\src\UglyToad.PdfPig\UglyToad.PdfPig.csproj" />
18+
<ProjectReference Include="..\..\src\UglyToad.PdfPig.Core\UglyToad.PdfPig.Core.csproj" />
19+
<ProjectReference Include="..\..\src\UglyToad.PdfPig.Fonts\UglyToad.PdfPig.Fonts.csproj" />
20+
<ProjectReference Include="..\..\src\UglyToad.PdfPig.Tokenization\UglyToad.PdfPig.Tokenization.csproj" />
21+
<ProjectReference Include="..\..\src\UglyToad.PdfPig.Tokens\UglyToad.PdfPig.Tokens.csproj" />
1822
<ProjectReference Include="..\..\src\UglyToad.PdfPig.DocumentLayoutAnalysis\UglyToad.PdfPig.DocumentLayoutAnalysis.csproj" />
1923
</ItemGroup>
2024

2125
<ItemGroup Condition="'$(PdfPigVersion)' == 'Latest'">
22-
<PackageReference Include="PdfPig" Version="0.1.14-alpha-20260216-7e370" />
26+
<PackageReference Include="PdfPig" Version="0.1.14-alpha-20260219-adb57" />
2327
</ItemGroup>
2428

2529
<ItemGroup>
30+
<None Update="algo.pdf">
31+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
32+
</None>
2633
<None Update="fseprd1102849.pdf">
2734
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
2835
</None>
36+
<None Update="PDFBOX-492-4.jar-8.pdf">
37+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
38+
</None>
39+
<None Update="Single Page Simple - from inkscape.pdf">
40+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
41+
</None>
42+
<None Update="Single Page Simple - from open office.pdf">
43+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
44+
</None>
2945
</ItemGroup>
3046

3147
</Project>
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
<Solution>
2+
<Folder Name="/PdfPig/">
3+
<Project Path="../../src/UglyToad.PdfPig.Core/UglyToad.PdfPig.Core.csproj" />
4+
<Project Path="../../src/UglyToad.PdfPig.DocumentLayoutAnalysis/UglyToad.PdfPig.DocumentLayoutAnalysis.csproj" />
5+
<Project Path="../../src/UglyToad.PdfPig.Fonts/UglyToad.PdfPig.Fonts.csproj" />
6+
<Project Path="../../src/UglyToad.PdfPig.Tokenization/UglyToad.PdfPig.Tokenization.csproj" />
7+
<Project Path="../../src/UglyToad.PdfPig.Tokens/UglyToad.PdfPig.Tokens.csproj" />
8+
<Project Path="../../src/UglyToad.PdfPig/UglyToad.PdfPig.csproj" />
9+
</Folder>
210
<Folder Name="/Solution Items/" />
3-
<Project Path="../../src/UglyToad.PdfPig.DocumentLayoutAnalysis/UglyToad.PdfPig.DocumentLayoutAnalysis.csproj" />
4-
<Project Path="../../src/UglyToad.PdfPig/UglyToad.PdfPig.csproj" />
511
<Project Path="UglyToad.PdfPig.Benchmarks.csproj" />
612
</Solution>
24.8 MB
Binary file not shown.

0 commit comments

Comments
 (0)