Skip to content

Commit

Permalink
Merge pull request #115 from Numpsy/extension_bench
Browse files Browse the repository at this point in the history
Add a couple of benchmarks for AsOLEPropertiesContainer
  • Loading branch information
ironfede authored Feb 25, 2024
2 parents 4d660b9 + 2d2bdba commit b1b68b5
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
41 changes: 41 additions & 0 deletions sources/Test/OpenMcdf.Benchmark/Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.IO;
using BenchmarkDotNet.Attributes;
using OpenMcdf.Extensions;

namespace OpenMcdf.Benchmark
{
// Simple benchmarks for reading OLE Properties with OpenMcdf.Extensions.
[SimpleJob(BenchmarkDotNet.Jobs.RuntimeMoniker.NetCoreApp31)]
[MemoryDiagnoser]
public class ExtensionsRead
{
// Keep the Storage as a member, as we're only testing the OLEProperties bits, not the underlying CompoundFile
private readonly CompoundFile udTestFile;

// Load the test file on creation
public ExtensionsRead()
{
string testFile = Path.Combine("TestFiles", "winUnicodeDictionary.doc");
this.udTestFile = new CompoundFile(testFile);
}

[GlobalCleanup]
public void GlobalCleanup()
{
udTestFile.Close();
}

[Benchmark]
public void TestReadSummaryInformation()
{
this.udTestFile.RootStorage.GetStream("\u0005SummaryInformation").AsOLEPropertiesContainer();
}

[Benchmark]
public void TestReadDocumentSummaryInformation()
{
this.udTestFile.RootStorage.GetStream("\u0005DocumentSummaryInformation").AsOLEPropertiesContainer();
}
}
}
13 changes: 12 additions & 1 deletion sources/Test/OpenMcdf.Benchmark/OpenMcdf.Benchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,22 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\OpenMcdf.Extensions\OpenMcdf.Extensions.csproj" />
<ProjectReference Include="..\..\OpenMcdf\OpenMcdf.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="TestFiles\" />
</ItemGroup>

<ItemGroup>
<None Include="..\TestFiles\winUnicodeDictionary.doc" Link="TestFiles\winUnicodeDictionary.doc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion sources/Test/OpenMcdf.Benchmark/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ internal class Program
{
private static void Main(string[] args)
{
var summary = BenchmarkRunner.Run<InMemory>();
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
}
}
}

0 comments on commit b1b68b5

Please sign in to comment.