diff --git a/sources/Test/OpenMcdf.Benchmark/Extensions.cs b/sources/Test/OpenMcdf.Benchmark/Extensions.cs new file mode 100644 index 00000000..1781476f --- /dev/null +++ b/sources/Test/OpenMcdf.Benchmark/Extensions.cs @@ -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(); + } + } +} \ No newline at end of file diff --git a/sources/Test/OpenMcdf.Benchmark/OpenMcdf.Benchmark.csproj b/sources/Test/OpenMcdf.Benchmark/OpenMcdf.Benchmark.csproj index cd12f4e0..f20af7c3 100644 --- a/sources/Test/OpenMcdf.Benchmark/OpenMcdf.Benchmark.csproj +++ b/sources/Test/OpenMcdf.Benchmark/OpenMcdf.Benchmark.csproj @@ -6,11 +6,22 @@ - + + + + + + + + + PreserveNewest + + + diff --git a/sources/Test/OpenMcdf.Benchmark/Program.cs b/sources/Test/OpenMcdf.Benchmark/Program.cs index f441ba1d..a6459efa 100644 --- a/sources/Test/OpenMcdf.Benchmark/Program.cs +++ b/sources/Test/OpenMcdf.Benchmark/Program.cs @@ -6,7 +6,7 @@ internal class Program { private static void Main(string[] args) { - var summary = BenchmarkRunner.Run(); + BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); } } } \ No newline at end of file