-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
58 changed files
with
2,084 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
############################################################################### | ||
# Set default behavior to automatically normalize line endings. | ||
############################################################################### | ||
* text=auto | ||
|
||
############################################################################### | ||
# Set default behavior for command prompt diff. | ||
# | ||
# This is need for earlier builds of msysgit that does not have it on by | ||
# default for csharp files. | ||
# Note: This is only used by command line | ||
############################################################################### | ||
#*.cs diff=csharp | ||
|
||
############################################################################### | ||
# Set the merge driver for project and solution files | ||
# | ||
# Merging from the command prompt will add diff markers to the files if there | ||
# are conflicts (Merging from VS is not affected by the settings below, in VS | ||
# the diff markers are never inserted). Diff markers may cause the following | ||
# file extensions to fail to load in VS. An alternative would be to treat | ||
# these files as binary and thus will always conflict and require user | ||
# intervention with every merge. To do so, just uncomment the entries below | ||
############################################################################### | ||
#*.sln merge=binary | ||
#*.csproj merge=binary | ||
#*.vbproj merge=binary | ||
#*.vcxproj merge=binary | ||
#*.vcproj merge=binary | ||
#*.dbproj merge=binary | ||
#*.fsproj merge=binary | ||
#*.lsproj merge=binary | ||
#*.wixproj merge=binary | ||
#*.modelproj merge=binary | ||
#*.sqlproj merge=binary | ||
#*.wwaproj merge=binary | ||
|
||
############################################################################### | ||
# behavior for image files | ||
# | ||
# image files are treated as binary by default. | ||
############################################################################### | ||
#*.jpg binary | ||
#*.png binary | ||
#*.gif binary | ||
|
||
############################################################################### | ||
# diff behavior for common document formats | ||
# | ||
# Convert binary document formats to text before diffing them. This feature | ||
# is only available from the command line. Turn it on by uncommenting the | ||
# entries below. | ||
############################################################################### | ||
#*.doc diff=astextplain | ||
#*.DOC diff=astextplain | ||
#*.docx diff=astextplain | ||
#*.DOCX diff=astextplain | ||
#*.dot diff=astextplain | ||
#*.DOT diff=astextplain | ||
#*.pdf diff=astextplain | ||
#*.PDF diff=astextplain | ||
#*.rtf diff=astextplain | ||
#*.RTF diff=astextplain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
# Remove the line below if you want to inherit .editorconfig settings from higher directories | ||
root = true | ||
|
||
dotnet_analyzer_diagnostic.category-Design.severity = warning | ||
dotnet_analyzer_diagnostic.category-Interoperability.severity = suggestion | ||
dotnet_analyzer_diagnostic.category-Maintainability.severity = warning | ||
dotnet_analyzer_diagnostic.category-Naming.severity = warning | ||
dotnet_analyzer_diagnostic.category-Performance.severity = warning | ||
dotnet_analyzer_diagnostic.category-Reliability.severity = warning | ||
dotnet_analyzer_diagnostic.category-Style.severity = warning | ||
|
||
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.DocumentationRules.severity = none | ||
|
||
# IDE0010: Populate switch | ||
dotnet_diagnostic.IDE0010.severity = none | ||
|
||
# IDE0011: Add braces to 'if' statement | ||
dotnet_diagnostic.IDE0011.severity = suggestion | ||
|
||
# IDE0022: Use expression body for method | ||
dotnet_diagnostic.IDE0022.severity = suggestion | ||
|
||
# IDE0025: Use expression body for property | ||
dotnet_diagnostic.IDE0025.severity = suggestion | ||
|
||
# IDE0028: Collection initialization can be simplified (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0028) | ||
dotnet_diagnostic.IDE0028.severity = none | ||
|
||
# IDE0028: Collection initialization can be simplified (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0028) | ||
dotnet_diagnostic.IDE0030.severity = suggestion | ||
|
||
# IDE0040: Accessibility modifiers required (disabled on build) | ||
dotnet_diagnostic.IDE0040.severity = none | ||
|
||
# IDE0045: Use conditional expression for assignment | ||
dotnet_diagnostic.IDE0045.severity = suggestion | ||
|
||
# IDE0046: Use conditional expression for return | ||
dotnet_diagnostic.IDE0046.severity = none | ||
|
||
# IDE0047: Parentheses can be removed | ||
dotnet_diagnostic.IDE0047.severity = suggestion | ||
|
||
# IDE0052: Remove unread private member | ||
dotnet_diagnostic.IDE0052.severity = warning | ||
|
||
# IDE0058: Expression value is never used | ||
dotnet_diagnostic.IDE0058.severity = suggestion | ||
|
||
# IDE0060: Remove unused parameter | ||
dotnet_diagnostic.IDE0060.severity = suggestion | ||
|
||
# IDE0072: Populate switch | ||
dotnet_diagnostic.IDE0072.severity = none | ||
|
||
# IDE0130: Namespace does not match folder structure | ||
dotnet_diagnostic.IDE0130.severity = suggestion | ||
|
||
# IDE0251: Make member readonly | ||
dotnet_diagnostic.IDE0251.severity = warning | ||
|
||
# IDE0270: Null check can be simplified | ||
dotnet_diagnostic.IDE0270.severity = suggestion | ||
|
||
# IDE0290: Use primary constructor | ||
dotnet_diagnostic.IDE0290.severity = suggestion | ||
|
||
# IDE0300: Collection initialization can be simplified | ||
dotnet_diagnostic.IDE0300.severity = suggestion | ||
|
||
# IDE0300: Collection initialization can be simplified (false positive on empty arrays) | ||
dotnet_diagnostic.IDE0301.severity = suggestion | ||
|
||
# IDE0303: Collection initialization can be simplified | ||
dotnet_diagnostic.IDE0302.severity = suggestion | ||
|
||
# IDE0303: Collection initialization can be simplified | ||
dotnet_diagnostic.IDE0303.severity = suggestion | ||
|
||
# IDE0305: Collection initialization can be simplified | ||
dotnet_diagnostic.IDE0305.severity = suggestion | ||
|
||
#CA1008: Enums should have zero value | ||
dotnet_diagnostic.CA1008.severity = suggestion | ||
|
||
# CA1028: Enum storage should be Int32 | ||
dotnet_diagnostic.CA1028.severity = suggestion | ||
|
||
# CA1031: Do not catch general exception types | ||
dotnet_diagnostic.CA1031.severity = suggestion | ||
|
||
# CA1051: Do not declare visible instance fields | ||
dotnet_diagnostic.CA1051.severity = none | ||
|
||
# CA1062: Validate arguments of public methods | ||
dotnet_diagnostic.CA1062.severity = none | ||
|
||
# CA1304: Specify CultureInfo | ||
dotnet_diagnostic.CA1304.severity = suggestion | ||
|
||
# CA1305: Specify IFormatProvider | ||
dotnet_diagnostic.CA1305.severity = suggestion | ||
|
||
# CA1308: Normalize strings to uppercase | ||
dotnet_diagnostic.CA1308.severity = suggestion | ||
|
||
# CA1309: Use ordinal string comparison | ||
dotnet_diagnostic.CA1309.severity = suggestion | ||
|
||
# CA1416: Validate platform compatibility | ||
dotnet_diagnostic.CA1416.severity = none | ||
|
||
# CA1848: Use the LoggerMessage delegates | ||
dotnet_diagnostic.CA1848.severity = none | ||
|
||
# CA1711: Identifiers should not have incorrect suffix | ||
dotnet_code_quality.CA1711.allowed_suffixes = Flag|Flags | ||
|
||
# CA1721: Property names should not match get methods | ||
dotnet_diagnostic.CA1721.severity = suggestion | ||
|
||
# CA1724: Type names should not match namespaces | ||
dotnet_diagnostic.CA1724.severity = suggestion | ||
|
||
# CA1814: Prefer jagged arrays over multidimensional | ||
dotnet_diagnostic.CA1814.severity = suggestion | ||
|
||
# CA1826: Use property instead of Linq Enumerable method | ||
dotnet_code_quality.CA1826.exclude_ordefault_methods = true | ||
|
||
# CA1863: Use 'CompositeFormat' | ||
dotnet_diagnostic.CA1863.severity = none | ||
|
||
# CA2007: Do not directly await a Task | ||
dotnet_diagnostic.CA2007.severity = suggestion | ||
|
||
# CA2008: Do not create tasks without passing a TaskScheduler | ||
dotnet_diagnostic.CA2008.severity = suggestion | ||
|
||
# CA2109: Review visible event handlers | ||
dotnet_diagnostic.CA2109.severity = none | ||
|
||
# CA2229: Implement serialization constructors | ||
dotnet_diagnostic.CA2229.severity = none | ||
|
||
# CA2300: Do not use insecure deserializer BinaryFormatter | ||
dotnet_diagnostic.CA2300.severity = none | ||
|
||
# CA2302: Ensure BinaryFormatter.Binder is set before calling BinaryFormatter.Deserialize | ||
dotnet_diagnostic.CA2302.severity = suggestion | ||
|
||
# CA5392: Use DefaultDllImportSearchPaths attribute for P/Invokes | ||
dotnet_diagnostic.CA5392.severity = suggestion | ||
|
||
# CA5393: Do not use unsafe DllImportSearchPath value | ||
dotnet_diagnostic.CA5393.severity = none | ||
|
||
# CA5394: Do not use insecure randomness | ||
dotnet_diagnostic.CA5394.severity = suggestion | ||
|
||
# CS1591: Missing XML comment for publicly visible type or member | ||
dotnet_diagnostic.CS1591.severity = none | ||
|
||
# MSTEST0015: Test method should not be ignored | ||
dotnet_diagnostic.MSTEST0015.severity = none | ||
|
||
# SYSLIB0011: Type or member is obsolete | ||
dotnet_diagnostic.SYSLIB0011.severity = none | ||
|
||
# SA0001: XML comment analysis disabled | ||
dotnet_diagnostic.SA0001.severity = none | ||
|
||
# SA1215: An instance readonly element is positioned beneath an instance non-readonly element of the same type | ||
dotnet_diagnostic.SA1215.severity = warning | ||
|
||
# SA1515: Single-line comment should be preceded by blank line | ||
dotnet_diagnostic.SA1515.severity = suggestion | ||
|
||
# SA1628: Documentation text should begin with a capital letter | ||
dotnet_diagnostic.SA1628.severity = warning | ||
|
||
# SA1201: Elements must appear in the correct order | ||
dotnet_diagnostic.SA1201.severity = suggestion | ||
|
||
# SYSLIB1045: Use GeneratedRegexAttribute to generate the regular expression implementation at compile time | ||
dotnet_diagnostic.SYSLIB1045.severity = suggestion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Order; | ||
using OpenMcdf; | ||
|
||
namespace OpenMcdf3.Benchmark; | ||
|
||
[SimpleJob] | ||
[CsvExporter] | ||
[HtmlExporter] | ||
[MarkdownExporter] | ||
//[DryCoreJob] // I always forget this attribute, so please leave it commented out | ||
[MemoryDiagnoser] | ||
[Orderer(SummaryOrderPolicy.FastestToSlowest)] | ||
public class InMemory : IDisposable | ||
{ | ||
private const int Kb = 1024; | ||
private const int Mb = Kb * Kb; | ||
private const string storageName = "MyStorage"; | ||
private const string streamName = "MyStream"; | ||
|
||
private byte[] _readBuffer; | ||
|
||
private MemoryStream _stream; | ||
|
||
[Params(Kb / 2, Kb, 4 * Kb, 128 * Kb, 256 * Kb, 512 * Kb, Kb * Kb)] | ||
public int BufferSize { get; set; } | ||
|
||
[Params(Mb /*, 8 * Mb, 64 * Mb, 128 * Mb*/)] | ||
public int TotalStreamSize { get; set; } | ||
|
||
public void Dispose() | ||
{ | ||
_stream?.Dispose(); | ||
} | ||
|
||
[GlobalSetup] | ||
public void GlobalSetup() | ||
{ | ||
_stream = new MemoryStream(); | ||
//_stream = File.Create("D:\\test.cfb"); | ||
_readBuffer = new byte[BufferSize]; | ||
CreateFile(1); | ||
} | ||
|
||
[GlobalCleanup] | ||
public void GlobalCleanup() | ||
{ | ||
_stream.Dispose(); | ||
_stream = null; | ||
_readBuffer = null; | ||
} | ||
|
||
[Benchmark] | ||
public void Test() | ||
{ | ||
// | ||
_stream.Seek(0L, SeekOrigin.Begin); | ||
// | ||
using var compoundFile = RootStorage.Open(_stream); | ||
using Stream cfStream = compoundFile.OpenStream(streamName + 0); | ||
long streamSize = cfStream.Length; | ||
long position = 0L; | ||
while (true) | ||
{ | ||
if (position >= streamSize) | ||
break; | ||
int read = cfStream.Read(_readBuffer, 0, _readBuffer.Length); | ||
position += read; | ||
if (read <= 0) break; | ||
} | ||
|
||
//compoundFile.Close(); | ||
} | ||
|
||
private void CreateFile(int streamCount) | ||
{ | ||
var iterationCount = TotalStreamSize / BufferSize; | ||
|
||
var buffer = new byte[BufferSize]; | ||
Array.Fill(buffer, byte.MaxValue); | ||
const CFSConfiguration flags = CFSConfiguration.Default | CFSConfiguration.LeaveOpen; | ||
using (var compoundFile = new CompoundFile(CFSVersion.Ver_3, flags)) | ||
{ | ||
//var st = compoundFile.RootStorage.AddStorage(storageName); | ||
var st = compoundFile.RootStorage; | ||
for (var streamId = 0; streamId < streamCount; ++streamId) | ||
{ | ||
var sm = st.AddStream(streamName + streamId); | ||
|
||
for (var iteration = 0; iteration < iterationCount; ++iteration) sm.Append(buffer); | ||
} | ||
|
||
compoundFile.Save(_stream); | ||
compoundFile.Close(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" /> | ||
<PackageReference Include="OpenMcdf" Version="2.3.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\OpenMcdf3\OpenMcdf3.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using BenchmarkDotNet.Running; | ||
|
||
namespace OpenMcdf3.Benchmarks; | ||
|
||
internal class Program | ||
{ | ||
private static void Main(string[] args) | ||
{ | ||
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); | ||
} | ||
} |
Oops, something went wrong.