Skip to content

Commit c85049d

Browse files
committed
updated comment for benchmarks
1 parent 7f06a6e commit c85049d

5 files changed

Lines changed: 48 additions & 35 deletions

File tree

benchmarks/PolylineAlgorithm.Benchmarks/PolylineBenchmark.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ namespace PolylineAlgorithm.Benchmarks;
1111
using PolylineAlgorithm.Utility;
1212

1313
/// <summary>
14-
/// Benchmarks for the <see cref="PolylineValue"/> struct.
14+
/// Benchmarks for <see cref="Polyline"/>.
1515
/// </summary>
1616
public class PolylineBenchmark {
1717
private static readonly Consumer _consumer = new();
1818

19+
/// <summary>
20+
/// Number of coordinates for benchmarks. Set by BenchmarkDotNet.
21+
/// </summary>
1922
[Params(1, 100, 1_000)]
2023
public int CoordinatesCount;
2124

@@ -45,6 +48,11 @@ public class PolylineBenchmark {
4548
/// </summary>
4649
public Polyline PolylineNotEqualValue { get; private set; }
4750

51+
/// <summary>
52+
/// Gets the destination array used for benchmarking the <see cref="Polyline.CopyTo(char[])"/> method.
53+
/// This array is initialized in <see cref="SetupData"/> to match the length of the encoded polyline,
54+
/// and is used as the target buffer for copying polyline data during benchmark runs.
55+
/// </summary>
4856
public char[] CopyToDestination { get; private set; }
4957

5058
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
@@ -65,7 +73,7 @@ public void SetupData() {
6573
}
6674

6775
/// <summary>
68-
/// Benchmarks the encoding of a list of coordinates into a polyline.
76+
/// Benchmark: create polyline from string.
6977
/// </summary>
7078
/// <returns>The encoded polyline.</returns>
7179
[Benchmark]
@@ -77,7 +85,7 @@ public void Polyline_FromString() {
7785
}
7886

7987
/// <summary>
80-
/// Benchmarks the encoding of an enumeration of coordinates into a polyline.
88+
/// Benchmark: create polyline from char array.
8189
/// </summary>
8290
/// <returns>The encoded polyline.</returns>
8391
[Benchmark]
@@ -89,7 +97,7 @@ public void Polyline_FromCharArray() {
8997
}
9098

9199
/// <summary>
92-
/// Benchmarks the encoding of an enumeration of coordinates into a polyline.
100+
/// Benchmark: create polyline from memory.
93101
/// </summary>
94102
/// <returns>The encoded polyline.</returns>
95103
[Benchmark]
@@ -101,7 +109,7 @@ public void Polyline_FromMemory() {
101109
}
102110

103111
/// <summary>
104-
/// Benchmarks the encoding of an enumeration of coordinates into a polyline.
112+
/// Benchmark: convert polyline to string.
105113
/// </summary>
106114
/// <returns>The encoded polyline.</returns>
107115
[Benchmark]
@@ -114,7 +122,7 @@ public void Polyline_ToString() {
114122

115123

116124
/// <summary>
117-
/// Benchmarks the encoding of an enumeration of coordinates into a polyline.
125+
/// Benchmark: copy polyline to array.
118126
/// </summary>
119127
/// <returns>The encoded polyline.</returns>
120128
[Benchmark]
@@ -127,7 +135,7 @@ public void Polyline_CopyTo() {
127135
}
128136

129137
/// <summary>
130-
/// Benchmarks the encoding of an enumeration of coordinates into a polyline.
138+
/// Benchmark: compare polyline with same value.
131139
/// </summary>
132140
/// <returns>The encoded polyline.</returns>
133141
[Benchmark]
@@ -139,7 +147,7 @@ public void Polyline_Equals_SameValue() {
139147
}
140148

141149
/// <summary>
142-
/// Benchmarks the encoding of an enumeration of coordinates into a polyline.
150+
/// Benchmark: compare polyline with different value.
143151
/// </summary>
144152
/// <returns>The encoded polyline.</returns>
145153
[Benchmark]
@@ -152,7 +160,7 @@ public void Polyline_Equals_DifferentValue() {
152160

153161

154162
/// <summary>
155-
/// Benchmarks the encoding of an enumeration of coordinates into a polyline.
163+
/// Benchmark: compare polyline with different type.
156164
/// </summary>
157165
/// <returns>The encoded polyline.</returns>
158166
[Benchmark]

benchmarks/PolylineAlgorithm.Benchmarks/PolylineDecoderBenchmark.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace PolylineAlgorithm.Benchmarks;
1212
using PolylineAlgorithm.Utility;
1313

1414
/// <summary>
15-
/// Benchmarks for the <see cref="PolylineDecoder"/> class.
15+
/// Benchmarks for <see cref="PolylineDecoder"/>.
1616
/// </summary>
1717
public class PolylineDecoderBenchmark {
1818
private readonly Consumer _consumer = new();
@@ -22,34 +22,34 @@ public class PolylineDecoderBenchmark {
2222

2323
#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.
2424
/// <summary>
25-
/// Gets the string value representing the encoded polyline.
25+
/// Polyline instance for benchmarks.
2626
/// </summary>
2727
public Polyline Polyline { get; private set; }
2828

2929
/// <summary>
30-
/// Gets the string value representing the encoded polyline.
30+
/// Encoded polyline as string.
3131
/// </summary>
3232
public string String { get; private set; }
3333

3434
/// <summary>
35-
/// Gets the string value representing the encoded polyline.
35+
/// Encoded polyline as char array.
3636
/// </summary>
3737
public char[] CharArray { get; private set; }
3838

3939
/// <summary>
40-
/// Gets the string value representing the encoded polyline.
40+
/// Encoded polyline as read-only memory.
4141
/// </summary>
4242
public ReadOnlyMemory<char> Memory { get; private set; }
4343

4444
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
4545

4646
/// <summary>
47-
/// The polyline decoder instance.
47+
/// Polyline decoder instance.
4848
/// </summary>
4949
public readonly PolylineDecoder Decoder = new();
5050

5151
/// <summary>
52-
/// Sets up the data for the benchmarks.
52+
/// Sets up benchmark data.
5353
/// </summary>
5454
[GlobalSetup]
5555
public void SetupData() {
@@ -60,7 +60,7 @@ public void SetupData() {
6060
}
6161

6262
/// <summary>
63-
/// Benchmarks the decoding of a polyline from a string.
63+
/// Benchmark: decode polyline instance.
6464
/// </summary>
6565
[Benchmark]
6666
public void PolylineDecoder_Decode_Polyline() {
@@ -70,7 +70,7 @@ public void PolylineDecoder_Decode_Polyline() {
7070
}
7171

7272
/// <summary>
73-
/// Benchmarks the decoding of a polyline from a string.
73+
/// Benchmark: decode from string.
7474
/// </summary>
7575
[Benchmark]
7676
public void PolylineDecoder_Decode_String() {
@@ -80,7 +80,7 @@ public void PolylineDecoder_Decode_String() {
8080
}
8181

8282
/// <summary>
83-
/// Benchmarks the decoding of a polyline from a string.
83+
/// Benchmark: decode from char array.
8484
/// </summary>
8585
[Benchmark]
8686
public void PolylineDecoder_Decode_CharArray() {
@@ -90,7 +90,7 @@ public void PolylineDecoder_Decode_CharArray() {
9090
}
9191

9292
/// <summary>
93-
/// Benchmarks the decoding of a polyline from a string.
93+
/// Benchmark: decode from memory.
9494
/// </summary>
9595
[Benchmark]
9696
public void PolylineDecoder_Decode_Memory() {

benchmarks/PolylineAlgorithm.Benchmarks/PolylineEncoderBenchmark.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,42 @@ namespace PolylineAlgorithm.Benchmarks;
1313
using System.Collections.Generic;
1414

1515
/// <summary>
16-
/// Benchmarks for the <see cref="PolylineEncoder"/> class.
16+
/// Benchmarks for <see cref="PolylineEncoder"/>.
1717
/// </summary>
1818
public class PolylineEncoderBenchmark {
1919
private readonly Consumer _consumer = new();
2020

21+
/// <summary>
22+
/// Number of coordinates for benchmarks.
23+
/// </summary>
2124
[Params(1, 100, 1_000)]
2225
public int CoordinatesCount;
2326

2427
#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.
2528
/// <summary>
26-
/// Gets the list of coordinates to be encoded.
29+
/// Coordinates as list.
2730
/// </summary>
2831
public List<Coordinate> List { get; private set; }
2932

3033
/// <summary>
31-
/// Gets the list of coordinates to be encoded.
34+
/// Coordinates as array.
3235
/// </summary>
3336
public Coordinate[] Array { get; private set; }
3437

3538
/// <summary>
36-
/// Gets the list of coordinates to be encoded.
39+
/// Coordinates as read-only memory.
3740
/// </summary>
3841
public ReadOnlyMemory<Coordinate> Memory { get; private set; }
3942

4043
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
4144

4245
/// <summary>
43-
/// The polyline encoder instance.
46+
/// Polyline encoder instance.
4447
/// </summary>
4548
public readonly PolylineEncoder Encoder = new();
4649

4750
/// <summary>
48-
/// Sets up the data for the benchmarks.
51+
/// Sets up benchmark data.
4952
/// </summary>
5053
[GlobalSetup]
5154
public void SetupData() {
@@ -55,9 +58,9 @@ public void SetupData() {
5558
}
5659

5760
/// <summary>
58-
/// Benchmarks the encoding of a list of coordinates into a polyline.
61+
/// Benchmark: encode coordinates from span.
5962
/// </summary>
60-
/// <returns>The encoded polyline.</returns>
63+
/// <returns>Encoded polyline.</returns>
6164
[Benchmark]
6265
public void PolylineEncoder_Encode_Span() {
6366
var polyline = Encoder
@@ -67,9 +70,9 @@ public void PolylineEncoder_Encode_Span() {
6770
}
6871

6972
/// <summary>
70-
/// Benchmarks the encoding of a list of coordinates into a polyline.
73+
/// Benchmark: encode coordinates from array.
7174
/// </summary>
72-
/// <returns>The encoded polyline.</returns>
75+
/// <returns>Encoded polyline.</returns>
7376
[Benchmark]
7477
public void PolylineEncoder_Encode_Array() {
7578
var polyline = Encoder
@@ -79,9 +82,9 @@ public void PolylineEncoder_Encode_Array() {
7982
}
8083

8184
/// <summary>
82-
/// Benchmarks the encoding of a list of coordinates into a polyline.
85+
/// Benchmark: encode coordinates from list.
8386
/// </summary>
84-
/// <returns>The encoded polyline.</returns>
87+
/// <returns>Encoded polyline.</returns>
8588
[Benchmark]
8689
public void PolylineEncoder_Encode_List() {
8790
var polyline = Encoder

benchmarks/PolylineAlgorithm.Benchmarks/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ namespace PolylineAlgorithm.Benchmarks;
88
using BenchmarkDotNet.Running;
99

1010
/// <summary>
11-
/// The main entry point for the benchmark application.
11+
/// Main entry point for benchmarks.
1212
/// </summary>
1313
internal class Program {
1414
/// <summary>
15-
/// The main method that runs the benchmarks.
15+
/// Runs the benchmarks.
1616
/// </summary>
17-
/// <param name="args">The command-line arguments.</param>
17+
/// <param name="args">Command-line arguments.</param>
1818
static void Main(string[] args) {
1919
BenchmarkSwitcher
2020
.FromAssembly(typeof(Program).Assembly)

src/PolylineAlgorithm/Abstraction/AbstractPolylineEncoder.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ protected AbstractPolylineEncoder(PolylineEncodingOptions options) {
6464
/// <exception cref="ArgumentException">
6565
/// Thrown when <paramref name="coordinates"/> is an empty enumeration.
6666
/// </exception>
67+
/// <exception cref="InternalBufferOverflowException"></exception>
68+
/// <exception cref="InvalidOperationException"></exception>
6769
public TPolyline Encode(ReadOnlySpan<TCoordinate> coordinates) {
6870
const string OperationName = nameof(Encode);
6971

0 commit comments

Comments
 (0)