mirror of
https://github.com/UglyToad/PdfPig.git
synced 2026-03-10 00:23:29 +08:00
Fix Benchmarks solution and add BruteForceBenchmarks
This commit is contained in:
71
tools/UglyToad.PdfPig.Benchmarks/BruteForceBenchmarks.cs
Normal file
71
tools/UglyToad.PdfPig.Benchmarks/BruteForceBenchmarks.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
BIN
tools/UglyToad.PdfPig.Benchmarks/PDFBOX-492-4.jar-8.pdf
Normal file
BIN
tools/UglyToad.PdfPig.Benchmarks/PDFBOX-492-4.jar-8.pdf
Normal file
Binary file not shown.
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -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>
|
||||
@@ -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>
|
||||
|
||||
138721
tools/UglyToad.PdfPig.Benchmarks/algo.pdf
Normal file
138721
tools/UglyToad.PdfPig.Benchmarks/algo.pdf
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user