@@ -11,42 +11,28 @@ namespace PolylineAlgorithm.Comparison.Benchmarks;
11
11
using PolylineAlgorithm . Utility ;
12
12
using PolylinerNet ;
13
13
using System . Collections . Generic ;
14
- using System . Threading . Tasks ;
15
14
using PolylineEncoding = Cloudikka . PolylineAlgorithm . Encoding . PolylineEncoding ;
16
15
17
16
/// <summary>
18
17
/// Benchmarks for the <see cref="PolylineEncoder"/> class.
19
18
/// </summary>
20
19
[ RankColumn ]
21
20
public class PolylineEncoderBenchmark {
22
- [ Params ( 1 , 25 , 50 , 100 , 250 , 500 , 1_000 , 5_000 , 10_000 , 25_000 , 50_000 , 100_000 , 500_000 , 1_000_000 ) ]
21
+ [ Params ( 1 , 10 , 50 , 100 , 250 , 500 , 1_000 , 5_000 , 10_000 , 25_000 , 50_000 , 100_000 , 500_000 , 1_000_000 ) ]
23
22
public int Count ;
24
23
25
24
#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.
26
- /// <summary>
27
- /// Gets the enumeration of coordinates to be encoded.
28
- /// </summary>
29
- public static IEnumerable < Coordinate > PolylineAlgorithmEnumeration { get ; private set ; }
30
-
31
- /// <summary>
32
- /// Gets the list of coordinates to be encoded.
33
- /// </summary>
34
- public static List < Coordinate > PolylineAlgorithmList { get ; private set ; }
35
-
36
- /// <summary>
37
- /// Gets the enumeration of coordinates to be encoded.
38
- /// </summary>
39
- public static IEnumerable < ( double , double ) > CloudikkaEnumeration { get ; private set ; }
40
-
41
- /// <summary>
42
- /// Gets the list of coordinates to be encoded.
43
- /// </summary>
25
+ public IEnumerable < Coordinate > PolylineAlgorithmEnumeration { get ; private set ; }
26
+ public IEnumerable < ( double , double ) > CloudikkaEnumeration { get ; private set ; }
27
+ public IEnumerable < PolylinePoint > PolylinerEnumeration { get ; private set ; }
28
+ public IEnumerable < Polylines . PolylineCoordinate > PolylinesEnumeration { get ; private set ; }
29
+ public IEnumerable < Tuple < double , double > > PolylineUtilityEnumeration { get ; private set ; }
30
+ public List < Coordinate > PolylineAlgorithmList { get ; private set ; }
44
31
public List < ( double , double ) > CloudikkaList { get ; private set ; }
45
32
public List < PolylinePoint > PolylinerList { get ; private set ; }
46
33
public List < Polylines . PolylineCoordinate > PolylinesList { get ; private set ; }
47
34
public List < Tuple < double , double > > PolylineUtilityList { get ; private set ; }
48
35
49
-
50
36
#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.
51
37
52
38
/// <summary>
@@ -71,12 +57,15 @@ public class PolylineEncoderBenchmark {
71
57
[ GlobalSetup ]
72
58
public void SetupData ( ) {
73
59
PolylineAlgorithmEnumeration = ValueProvider . GetCoordinates ( Count ) ;
74
- PolylineAlgorithmList = [ .. PolylineAlgorithmEnumeration ] ;
75
60
CloudikkaEnumeration = PolylineAlgorithmEnumeration . Select ( c => ( c . Latitude , c . Longitude ) ) ;
61
+ PolylinerEnumeration = PolylineAlgorithmEnumeration . Select ( c => new PolylinePoint ( c . Latitude , c . Longitude ) ) ;
62
+ PolylinesEnumeration = PolylineAlgorithmEnumeration . Select ( c => new Polylines . PolylineCoordinate { Latitude = c . Latitude , Longitude = c . Longitude } ) ;
63
+ PolylineUtilityEnumeration = PolylineAlgorithmEnumeration . Select ( c => new Tuple < double , double > ( c . Latitude , c . Longitude ) ) ;
64
+ PolylineAlgorithmList = [ .. PolylineAlgorithmEnumeration ] ;
76
65
CloudikkaList = [ .. CloudikkaEnumeration ] ;
77
- PolylinerList = PolylineAlgorithmEnumeration . Select ( c => new PolylinePoint ( c . Latitude , c . Longitude ) ) . ToList ( ) ;
78
- PolylinesList = PolylineAlgorithmEnumeration . Select ( c => new Polylines . PolylineCoordinate { Latitude = c . Latitude , Longitude = c . Longitude } ) . ToList ( ) ;
79
- PolylineUtilityList = PolylineAlgorithmEnumeration . Select ( c => new Tuple < double , double > ( c . Latitude , c . Longitude ) ) . ToList ( ) ;
66
+ PolylinerList = [ .. PolylinerEnumeration ] ;
67
+ PolylinesList = [ .. PolylinesEnumeration ] ;
68
+ PolylineUtilityList = [ .. PolylineUtilityEnumeration ] ;
80
69
}
81
70
82
71
/// <summary>
@@ -112,6 +101,15 @@ public string Cloudikka_Encode_List() {
112
101
. Encode ( CloudikkaList ) ;
113
102
}
114
103
104
+ /// <summary>
105
+ /// Benchmarks the decoding of a polyline from read-only memory.
106
+ /// </summary>
107
+ [ Benchmark ]
108
+ public string PolylinerNet_Encode_Enumeration ( ) {
109
+ return PolylinerNet
110
+ . Encode ( [ .. PolylinerEnumeration ] ) ;
111
+ }
112
+
115
113
/// <summary>
116
114
/// Benchmarks the decoding of a polyline from read-only memory.
117
115
/// </summary>
@@ -122,6 +120,15 @@ public string PolylinerNet_Encode_List() {
122
120
}
123
121
124
122
123
+ /// <summary>
124
+ /// Benchmarks the decoding of a polyline from read-only memory.
125
+ /// </summary>
126
+ [ Benchmark ]
127
+ public string Polylines_Encode_Enumeration ( ) {
128
+ return Polylines . Polyline
129
+ . EncodePoints ( [ .. PolylinesEnumeration ] ) ;
130
+ }
131
+
125
132
/// <summary>
126
133
/// Benchmarks the decoding of a polyline from read-only memory.
127
134
/// </summary>
@@ -131,6 +138,15 @@ public string Polylines_Encode_List() {
131
138
. EncodePoints ( PolylinesList ) ;
132
139
}
133
140
141
+ /// <summary>
142
+ /// Benchmarks the decoding of a polyline from read-only memory.
143
+ /// </summary>
144
+ [ Benchmark ]
145
+ public string PolylineUtility_Encode_Enumeration ( ) {
146
+ return PolylineUtility
147
+ . Encode ( [ .. PolylineUtilityEnumeration ] ) ;
148
+ }
149
+
134
150
/// <summary>
135
151
/// Benchmarks the decoding of a polyline from read-only memory.
136
152
/// </summary>
0 commit comments