rspec/rules/S6609/resources-dotnet.adoc

68 lines
2.0 KiB
Plaintext

== Resources
=== Documentation
* https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.sortedset-1[SortedSet<T>]
* https://learn.microsoft.com/en-us/dotnet/api/system.collections.immutable.immutablesortedset-1[ImmutableSortedSet<T>]
* https://learn.microsoft.com/en-us/dotnet/api/system.collections.immutable.immutablesortedset-1.builder[ImmutableSortedSet<T>.Builder]
=== Benchmarks
[options="header"]
|===
| Method | Runtime | Mean | Standard Deviation | Allocated
| MaxMethod | .NET 7.0 | 68,961.483 us | 499.6623 us | 248063 B
| MaxProperty | .NET 7.0 | 4.638 us | 0.0634 us | -
| MaxMethod | .NET Framework 4.6.2 | 85,827.359 us | 1,531.1611 us | 281259 B
| MaxProperty | .NET Framework 4.6.2 | 67.682 us | 0.3757 us | 312919 B
|===
==== Glossary
* https://en.wikipedia.org/wiki/Arithmetic_mean[Mean]
* https://en.wikipedia.org/wiki/Standard_deviation[Standard Deviation]
* https://en.wikipedia.org/wiki/Memory_management[Allocated]
The results were generated by running the following snippet with https://github.com/dotnet/BenchmarkDotNet[BenchmarkDotNet]:
[source,csharp]
----
private SortedSet<string> data;
[Params(1_000)]
public int Iterations;
[GlobalSetup]
public void Setup() =>
data = new SortedSet<string>(Enumerable.Range(0, Iterations).Select(x => Guid.NewGuid().ToString()));
[Benchmark(Baseline = true)]
public void MaxMethod()
{
for (var i = 0; i < Iterations; i++)
{
_ = data.Max(); // Max() extension method
}
}
[Benchmark]
public void MaxProperty()
{
for (var i = 0; i < Iterations; i++)
{
_ = data.Max; // Max property
}
}
----
Hardware configuration:
[source]
----
BenchmarkDotNet=v0.13.5, OS=Windows 10 (10.0.19045.2846/22H2/2022Update)
11th Gen Intel Core i7-11850H 2.50GHz, 1 CPU, 16 logical and 8 physical cores
[Host] : .NET Framework 4.8 (4.8.4614.0), X64 RyuJIT VectorSize=256
.NET 7.0 : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2
.NET Framework 4.6.2 : .NET Framework 4.8 (4.8.4614.0), X64 RyuJIT VectorSize=256
----