2023-05-24 15:16:57 +02:00
|
|
|
== Resources
|
|
|
|
|
|
|
|
=== Documentation
|
|
|
|
|
|
|
|
* https://learn.microsoft.com/en-us/dotnet/api/system.string.startswith[string.StartsWith]
|
Modify rules S3260,S6610,S6612,S6613,S6617,S6618: Fix benchmark table (#3532)
* Fix benchmarks for S3260,S6610,S6612,S6613,S6617,S6618
* Review 1
2024-01-18 09:26:58 +01:00
|
|
|
* https://learn.microsoft.com/en-us/dotnet/api/system.string.endswith[string.EndsWith]
|
2023-05-24 15:16:57 +02:00
|
|
|
|
|
|
|
=== Benchmarks
|
|
|
|
|
|
|
|
[options="header"]
|
|
|
|
|===
|
Modify rules S3260,S6610,S6612,S6613,S6617,S6618: Fix benchmark table (#3532)
* Fix benchmarks for S3260,S6610,S6612,S6613,S6617,S6618
* Review 1
2024-01-18 09:26:58 +01:00
|
|
|
| Method | Mean | Standard Deviation
|
|
|
|
| StartsWith_String | 30.965 ms | 3.2732 ms
|
|
|
|
| StartsWith_Char | 7.568 ms | 0.3235 ms
|
|
|
|
| EndsWith_String | 30.421 ms | 5.1136 ms
|
|
|
|
| EndsWith_Char | 8.067 ms | 0.7092 ms
|
2023-05-24 15:16:57 +02:00
|
|
|
|===
|
|
|
|
|
Modify rules S3260,S6610,S6612,S6613,S6617,S6618: Fix benchmark table (#3532)
* Fix benchmarks for S3260,S6610,S6612,S6613,S6617,S6618
* Review 1
2024-01-18 09:26:58 +01:00
|
|
|
==== Glossary
|
|
|
|
|
|
|
|
* https://en.wikipedia.org/wiki/Arithmetic_mean[Mean]
|
|
|
|
* https://en.wikipedia.org/wiki/Standard_deviation[Standard Deviation]
|
|
|
|
|
2023-05-24 15:16:57 +02:00
|
|
|
The results were generated by running the following snippet with https://github.com/dotnet/BenchmarkDotNet[BenchmarkDotNet]:
|
|
|
|
|
|
|
|
[source,csharp]
|
|
|
|
----
|
|
|
|
private List<string> data;
|
|
|
|
|
|
|
|
[Params(1_000_000)]
|
|
|
|
public int N { get; set; }
|
|
|
|
|
|
|
|
[GlobalSetup]
|
|
|
|
public void Setup() =>
|
|
|
|
data = Enumerable.Range(0, N).Select(_ => Guid.NewGuid().ToString()).ToList();
|
|
|
|
|
|
|
|
[Benchmark]
|
|
|
|
public void StartsWith_String()
|
|
|
|
{
|
|
|
|
_ = data.Where(guid => guid.StartsWith("d")).ToList();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Benchmark]
|
|
|
|
public void StartsWith_Char()
|
|
|
|
{
|
|
|
|
_ = data.Where(guid => guid.StartsWith('d')).ToList();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Benchmark]
|
|
|
|
public void EndsWith_String()
|
|
|
|
{
|
|
|
|
_ = data.Where(guid => guid.EndsWith("d")).ToList();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Benchmark]
|
|
|
|
public void EndsWith_Char()
|
|
|
|
{
|
|
|
|
_ = data.Where(guid => guid.EndsWith('d')).ToList();
|
|
|
|
}
|
|
|
|
|
|
|
|
----
|
|
|
|
|
|
|
|
Hardware configuration:
|
|
|
|
|
2023-10-30 10:33:56 +01:00
|
|
|
[source,text]
|
|
|
|
----
|
2023-05-24 15:16:57 +02:00
|
|
|
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
|
|
|
|
.NET SDK=7.0.203
|
|
|
|
[Host] : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2
|
|
|
|
.NET 7.0 : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2
|
2023-10-30 10:33:56 +01:00
|
|
|
----
|