@@ -11,42 +11,28 @@ namespace PolylineAlgorithm.Comparison.Benchmarks;
1111using PolylineAlgorithm . Utility ;
1212using PolylinerNet ;
1313using System . Collections . Generic ;
14- using System . Threading . Tasks ;
1514using PolylineEncoding = Cloudikka . PolylineAlgorithm . Encoding . PolylineEncoding ;
1615
1716/// <summary>
1817/// Benchmarks for the <see cref="PolylineEncoder"/> class.
1918/// </summary>
2019[ RankColumn ]
2120public 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 ) ]
2322 public int Count ;
2423
2524#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 ; }
4431 public List < ( double , double ) > CloudikkaList { get ; private set ; }
4532 public List < PolylinePoint > PolylinerList { get ; private set ; }
4633 public List < Polylines . PolylineCoordinate > PolylinesList { get ; private set ; }
4734 public List < Tuple < double , double > > PolylineUtilityList { get ; private set ; }
4835
49-
5036#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.
5137
5238 /// <summary>
@@ -71,12 +57,15 @@ public class PolylineEncoderBenchmark {
7157 [ GlobalSetup ]
7258 public void SetupData ( ) {
7359 PolylineAlgorithmEnumeration = ValueProvider . GetCoordinates ( Count ) ;
74- PolylineAlgorithmList = [ .. PolylineAlgorithmEnumeration ] ;
7560 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 ] ;
7665 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 ] ;
8069 }
8170
8271 /// <summary>
@@ -112,6 +101,15 @@ public string Cloudikka_Encode_List() {
112101 . Encode ( CloudikkaList ) ;
113102 }
114103
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+
115113 /// <summary>
116114 /// Benchmarks the decoding of a polyline from read-only memory.
117115 /// </summary>
@@ -122,6 +120,15 @@ public string PolylinerNet_Encode_List() {
122120 }
123121
124122
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+
125132 /// <summary>
126133 /// Benchmarks the decoding of a polyline from read-only memory.
127134 /// </summary>
@@ -131,6 +138,15 @@ public string Polylines_Encode_List() {
131138 . EncodePoints ( PolylinesList ) ;
132139 }
133140
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+
134150 /// <summary>
135151 /// Benchmarks the decoding of a polyline from read-only memory.
136152 /// </summary>
0 commit comments