Skip to content

Commit e1236db

Browse files
committed
refactored PolylineBuilder benchmark
1 parent c287fbf commit e1236db

File tree

1 file changed

+4
-26
lines changed

1 file changed

+4
-26
lines changed

benchmarks/PolylineAlgorithm.Benchmarks/PolylineBuilderBenchmark.cs

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,16 @@ namespace PolylineAlgorithm.Benchmarks;
1616
[RankColumn]
1717
public class PolylineBuilderBenchmark {
1818
[Params(1, 10, 100, 500, 1_000)]
19-
public int Count;
19+
public int Length;
2020

2121
[Params(1, 5, 10, 50, 100)]
2222
public int SegmentsCount;
2323

2424
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
25-
/// <summary>
26-
/// Gets the character array representing the encoded polyline.
27-
/// </summary>
28-
public char[] CharArrayValue { get; private set; }
29-
3025
/// <summary>
3126
/// Gets the read-only memory representing the encoded polyline.
3227
/// </summary>
33-
public ReadOnlyMemory<char> MemoryValue { get; private set; }
34-
35-
36-
/// <summary>
37-
/// Gets the string value representing the encoded polyline.
38-
/// </summary>
39-
public string StringValue { get; private set; }
40-
41-
/// <summary>
42-
/// Gets the read-only memory representing the encoded polyline.
43-
/// </summary>
44-
public Polyline PolylineNotEqualValue { get; private set; }
45-
46-
public char[] CopyToDestination { get; private set; }
28+
internal ReadOnlyMemory<char> MemoryValue { get; private set; }
4729

4830
internal PolylineBuilder Builder { get; private set; }
4931

@@ -56,11 +38,7 @@ public class PolylineBuilderBenchmark {
5638
[GlobalSetup]
5739
public void SetupData() {
5840
Builder = new PolylineBuilder();
59-
60-
var polyline = RandomValueProvider.GetPolyline(Count);
61-
StringValue = polyline.ToString();
62-
CharArrayValue = [.. StringValue];
63-
MemoryValue = CharArrayValue.AsMemory();
41+
MemoryValue = RandomValueProvider.GetPolyline(Length).ToString().AsMemory();
6442
}
6543

6644
/// <summary>
@@ -69,7 +47,7 @@ public void SetupData() {
6947
/// <returns>The encoded polyline.</returns>
7048
[Benchmark]
7149
public Polyline PolylineBuilder_Append_Memory() {
72-
for(int i = 0; i < SegmentsCount; i++) {
50+
for (int i = 0; i < SegmentsCount; i++) {
7351
Builder
7452
.Append(MemoryValue);
7553
}

0 commit comments

Comments
 (0)