Skip to content

Commit 5977810

Browse files
author
Petr Sramek
committed
added documentation
1 parent f141217 commit 5977810

File tree

3 files changed

+65
-11
lines changed

3 files changed

+65
-11
lines changed

benchmarks/PolylineAlgorithm.Benchmarks/PolylineDecoderBenchmark.cs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,48 @@ namespace PolylineAlgorithm.Benchmarks;
99
using BenchmarkDotNet.Engines;
1010
using PolylineAlgorithm;
1111

12+
/// <summary>
13+
/// Benchmarks for the <see cref="PolylineDecoder"/> class.
14+
/// </summary>
1215
[RankColumn]
1316
public class PolylineDecoderBenchmark {
1417
private readonly Consumer _consumer = new();
1518

1619
#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.
20+
/// <summary>
21+
/// Gets the string value representing the encoded polyline.
22+
/// </summary>
1723
public string StringValue { get; private set; }
24+
25+
/// <summary>
26+
/// Gets the character array representing the encoded polyline.
27+
/// </summary>
1828
public char[] CharArray { get; private set; }
1929

20-
#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.
30+
/// <summary>
31+
/// Gets the read-only memory representing the encoded polyline.
32+
/// </summary>
2133
public ReadOnlyMemory<char> Memory { get; private set; }
34+
#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.
2235

23-
36+
/// <summary>
37+
/// The polyline decoder instance.
38+
/// </summary>
2439
public PolylineDecoder Decoder = new();
2540

41+
/// <summary>
42+
/// Sets up the data for the benchmarks.
43+
/// </summary>
2644
[GlobalSetup]
2745
public void SetupData() {
2846
StringValue = @"sq_|Fptm{UrbxoHinoiEuhmbHctjfc@`rocCt|nfJgiauLvc_uIh`pg_@h_fkVgctZoyqfW{rxgQhhymFpuvvDwqcfTlqbcBiegdTwf{uNngc|z@{vhlDnsi_B~nz`O}d_hNp{n`E}kcoKm`bCiul~\jhg|Hv{qoWshzh\{lf_G`pzMqm|bLzswoQbhcm`@b`}cIgignPgxntR|}vo^f~|}L}|_jBa|ujWuxkjQfj|w[wsz`Pmdb{XohnwA`srxWjitms@c_~`Tava_l@jxxcF`d|zHcpnaMnd{kYzccwPxzpiHfsxlL}jjjQqvdbIikyvj@cjdqTh`zoDzqleHnfmik@tbnoB_t}gFkzx_Ct_eiP`wxrBcd_|w@zlhfPtlxgBkwyyZn|~tFlpj|HxqiwUnddkFoo|nTee}dSfkcg`@py`uQiguom@zkkpEfcgkAntuuDzl~il@ir_gCrd~nI_ryeC_qmmMl_kgCz`qgFzkejBmlchYyp`hZ`_cuYzuc}Onqz}Ew~Gcsmj@lp{Hqj_gz@ne{pJnny~]g{tuNxbno[lfq_Lqhwjt@qn|cCuxnMyivuIh{|tR`ylsQlqbfO}rf`LxghfBg~{nAv`gdNbjh_Fglt|NfxwyBowwhW{bdtNdbkqe@rxtwSy{_fX{btm@va`_LkhwuUyqgzK`xdnKgbwsFigt_Mofdn\h|x[ccoPtbpvNz}skb@pl~xEqascV_wsx[`f_z]zewFs`zjAhturWxayhJqmfaAjmhhHxwuwF_aru@ojemVq|beu@kkucBdmryTevflDcbmdAnp|dHfpbd^io}z@e~}dFzcybQ}`hxOyt|bNl}blLnuspKk|t|k@itjfHt}}aVyzmcF_rgmLct}x@bazdq@loajBxygb@f}krVgnuqOcrx_Daqvp_@ew}yUn}kpU|uwnItashEpe_aHusi{Fsu}_Ewfhv[dzhzKxh_qXucxfXmynkGxuqbW|ppgi@vrsq@clryZk`bt^spkyP";
2947
CharArray = StringValue.ToCharArray();
3048
Memory = StringValue.AsMemory();
3149
}
3250

51+
/// <summary>
52+
/// Benchmarks the decoding of a polyline from a string.
53+
/// </summary>
3354
[Benchmark]
3455
public void PolylineDecoder_Decode_FromString() {
3556
Polyline polyline = Polyline.FromString(StringValue);
@@ -39,6 +60,9 @@ public void PolylineDecoder_Decode_FromString() {
3960
.Consume(_consumer);
4061
}
4162

63+
/// <summary>
64+
/// Benchmarks the decoding of a polyline from a character array.
65+
/// </summary>
4266
[Benchmark]
4367
public void PolylineDecoder_Decode_FromCharArray() {
4468
Polyline polyline = Polyline.FromCharArray(CharArray);
@@ -48,6 +72,9 @@ public void PolylineDecoder_Decode_FromCharArray() {
4872
.Consume(_consumer);
4973
}
5074

75+
/// <summary>
76+
/// Benchmarks the decoding of a polyline from read-only memory.
77+
/// </summary>
5178
[Benchmark]
5279
public void PolylineDecoder_Decode_FromMemory() {
5380
Polyline polyline = Polyline.FromMemory(Memory);
@@ -56,4 +83,4 @@ public void PolylineDecoder_Decode_FromMemory() {
5683
.Decode(in polyline)
5784
.Consume(_consumer);
5885
}
59-
}
86+
}

benchmarks/PolylineAlgorithm.Benchmarks/PolylineEncoderBenchmark.cs

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,54 @@ namespace PolylineAlgorithm.Benchmarks;
99
using PolylineAlgorithm;
1010
using System.Collections.Generic;
1111

12+
/// <summary>
13+
/// Benchmarks for the <see cref="PolylineEncoder"/> class.
14+
/// </summary>
1215
[RankColumn]
1316
public class PolylineEncoderBenchmark {
1417
private static readonly Random R = new();
1518

1619
#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.
20+
/// <summary>
21+
/// Gets the enumeration of coordinates to be encoded.
22+
/// </summary>
1723
public static IEnumerable<Coordinate> Enumeration { get; private set; }
1824

25+
/// <summary>
26+
/// Gets the list of coordinates to be encoded.
27+
/// </summary>
1928
public static List<Coordinate> List { get; private set; }
20-
2129
#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.
2230

31+
/// <summary>
32+
/// The polyline encoder instance.
33+
/// </summary>
2334
public PolylineEncoder Encoder = new();
2435

36+
/// <summary>
37+
/// Sets up the data for the benchmarks.
38+
/// </summary>
2539
[GlobalSetup]
2640
public void SetupData() {
2741
Enumeration = Enumerable.Range(0, 100).Select(i => new Coordinate(R.Next(-90, 90) + R.NextDouble(), R.Next(-180, 180) + R.NextDouble()));
28-
List = [.. Enumeration];
42+
List = new List<Coordinate>(Enumeration);
2943
}
3044

45+
/// <summary>
46+
/// Benchmarks the encoding of a list of coordinates into a polyline.
47+
/// </summary>
48+
/// <returns>The encoded polyline.</returns>
3149
[Benchmark]
3250
public Polyline PolylineEncoder_Encode_List() {
33-
return Encoder
34-
.Encode(List!);
51+
return Encoder.Encode(List!);
3552
}
3653

54+
/// <summary>
55+
/// Benchmarks the encoding of an enumeration of coordinates into a polyline.
56+
/// </summary>
57+
/// <returns>The encoded polyline.</returns>
3758
[Benchmark]
3859
public Polyline PolylineEncoder_Encode_Enumerator() {
39-
return Encoder
40-
.Encode(Enumeration!);
60+
return Encoder.Encode(Enumeration!);
4161
}
42-
}
62+
}

benchmarks/PolylineAlgorithm.Benchmarks/Program.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,17 @@ namespace PolylineAlgorithm.Benchmarks;
88
using BenchmarkDotNet.Configs;
99
using BenchmarkDotNet.Running;
1010

11+
/// <summary>
12+
/// The main entry point for the benchmark application.
13+
/// </summary>
1114
internal class Program {
15+
/// <summary>
16+
/// The main method that runs the benchmarks.
17+
/// </summary>
18+
/// <param name="args">The command-line arguments.</param>
1219
static void Main(string[] args) {
1320
BenchmarkSwitcher
1421
.FromAssembly(typeof(Program).Assembly)
1522
.Run(args, DefaultConfig.Instance);
1623
}
17-
}
24+
}

0 commit comments

Comments
 (0)