@@ -8,6 +8,10 @@ namespace PolylineAlgorithm.Benchmarks;
8
8
using BenchmarkDotNet . Attributes ;
9
9
using BenchmarkDotNet . Engines ;
10
10
using BenchmarkDotNet . Jobs ;
11
+ using BenchmarkDotNet . Order ;
12
+ using Cloudikka . PolylineAlgorithm . Encoding ;
13
+ using PolylineAlgorithm ;
14
+ using PolylinerNet ;
11
15
using System . Collections . Generic ;
12
16
13
17
[ RankColumn ]
@@ -17,25 +21,55 @@ namespace PolylineAlgorithm.Benchmarks;
17
21
[ SimpleJob ( RuntimeMoniker . Net70 ) ]
18
22
[ SimpleJob ( RuntimeMoniker . Net80 ) ]
19
23
[ SimpleJob ( RuntimeMoniker . Net90 ) ]
20
- [ Orderer ( BenchmarkDotNet . Order . SummaryOrderPolicy . Declared ) ]
24
+ [ Orderer ( SummaryOrderPolicy . Default ) ]
21
25
public class PolylineBenchmark {
22
26
private readonly Consumer _consumer = new ( ) ;
27
+ public static string String_Polyline { get ; } = "}adrJh}}cVazlw@uykyNhaqeE`vfzG_~kY}~`eTsr{~Cwn~aOty_g@thapJvvoqKxt{sStfahDmtvmIfmiqBhjq|HujpgComs{Z}dhdKcidPymnvBqmquE~qrfI`x{lPf|ftGn~}d_@q}saAurjmu@bwr_DxrfaK~{rO~bidPwfduXwlioFlpum@twvfFpmi~VzxcsOqyejYhh|i@pbnr[twvfF_ueUujvbSa_d~ZkcnjZla~f[pmquEebxo[j}nr@xnn|H{gyiKbh{yH`oenn@y{mpIrbd~EmipgH}fuov@hjqtTp|flAttvkFrym_d@|eyCwn~aOfvdNmeawM??{yxdUcidPca{}D_atqGenzcAlra{@trgWhn{aZ??tluqOgu~sH" ;
28
+ public static ReadOnlyMemory < char > Memory_Polyline { get ; } = String_Polyline . AsMemory ( ) ;
23
29
24
- public DefaultPolylineDecoder Decoder { get ; } = new DefaultPolylineDecoder ( ) ;
25
- public Polyline Polyline { get ; } = new Polyline ( "}adrJh}}cVazlw@uykyNhaqeE`vfzG_~kY}~`eTsr{~Cwn~aOty_g@thapJvvoqKxt{sStfahDmtvmIfmiqBhjq|HujpgComs{Z}dhdKcidPymnvBqmquE~qrfI`x{lPf|ftGn~}d_@q}saAurjmu@bwr_DxrfaK~{rO~bidPwfduXwlioFlpum@twvfFpmi~VzxcsOqyejYhh|i@pbnr[twvfF_ueUujvbSa_d~ZkcnjZla~f[pmquEebxo[j}nr@xnn|H{gyiKbh{yH`oenn@y{mpIrbd~EmipgH}fuov@hjqtTp|flAttvkFrym_d@|eyCwn~aOfvdNmeawM??{yxdUcidPca{}D_atqGenzcAlra{@trgWhn{aZ??tluqOgu~sH" ) ;
30
+ public static IEnumerable < Coordinate > PolylineAlgorithm_Coordinates { get ; } = [ new ( 60.81071 , - 121.40005 ) , new ( 70.05664 , - 38.43130 ) , new ( 37.52379 , - 84.83755 ) , new ( 41.85003 , 26.25620 ) , new ( 68.04709 , 110.63120 ) , new ( 61.48922 , 50.16245 ) , new ( - 4.46018 , - 58.11880 ) , new ( - 32.16061 , - 3.27505 ) , new ( - 50.89185 , - 55.30630 ) , new ( - 28.52070 , 90.94370 ) , new ( 35.26009 , 93.75620 ) , new ( 54.83622 , 128.91245 ) , new ( 1.16022 , 37.50620 ) , new ( - 44.26398 , - 131.24380 ) , new ( - 33.34325 , 154.22495 ) , new ( - 59.65879 , 90.94370 ) , new ( - 62.38215 , 0.94370 ) , new ( 72.32117 , 40.31870 ) , new ( 64.66910 , 2.34995 ) , new ( - 61.04971 , - 84.83755 ) , new ( 77.10238 , - 91.86880 ) , new ( - 72.88859 , - 129.83755 ) , new ( - 69.24987 , - 24.36880 ) , new ( 77.41254 , 119.06870 ) , new ( - 70.69409 , 83.91245 ) , new ( 78.85650 , 75.47495 ) , new ( 26.83989 , 140.16245 ) , new ( - 24.75069 , - 108.74380 ) , new ( 30.53968 , - 145.30630 ) , new ( 79.12503 , 145.78745 ) , new ( - 34.51006 , 133.13120 ) , new ( - 73.29753 , - 60.93130 ) , new ( - 74.08712 , 23.44370 ) , new ( - 76.57404 , 100.78745 ) , new ( - 76.57404 , 100.78745 ) , new ( 39.72082 , 103.59995 ) , new ( 70.99412 , 148.59995 ) , new ( 82.27591 , 138.75620 ) , new ( 78.29964 , - 3.27505 ) , new ( 78.29964 , - 3.27505 ) , new ( - 8.65039 , 47.34995 ) ] ;
31
+ public static List < PolylinePoint > PolylinerNet_PolylinePoint { get ; } = [ new ( 60.81071 , - 121.40005 ) , new ( 70.05664 , - 38.43130 ) , new ( 37.52379 , - 84.83755 ) , new ( 41.85003 , 26.25620 ) , new ( 68.04709 , 110.63120 ) , new ( 61.48922 , 50.16245 ) , new ( - 4.46018 , - 58.11880 ) , new ( - 32.16061 , - 3.27505 ) , new ( - 50.89185 , - 55.30630 ) , new ( - 28.52070 , 90.94370 ) , new ( 35.26009 , 93.75620 ) , new ( 54.83622 , 128.91245 ) , new ( 1.16022 , 37.50620 ) , new ( - 44.26398 , - 131.24380 ) , new ( - 33.34325 , 154.22495 ) , new ( - 59.65879 , 90.94370 ) , new ( - 62.38215 , 0.94370 ) , new ( 72.32117 , 40.31870 ) , new ( 64.66910 , 2.34995 ) , new ( - 61.04971 , - 84.83755 ) , new ( 77.10238 , - 91.86880 ) , new ( - 72.88859 , - 129.83755 ) , new ( - 69.24987 , - 24.36880 ) , new ( 77.41254 , 119.06870 ) , new ( - 70.69409 , 83.91245 ) , new ( 78.85650 , 75.47495 ) , new ( 26.83989 , 140.16245 ) , new ( - 24.75069 , - 108.74380 ) , new ( 30.53968 , - 145.30630 ) , new ( 79.12503 , 145.78745 ) , new ( - 34.51006 , 133.13120 ) , new ( - 73.29753 , - 60.93130 ) , new ( - 74.08712 , 23.44370 ) , new ( - 76.57404 , 100.78745 ) , new ( - 76.57404 , 100.78745 ) , new ( 39.72082 , 103.59995 ) , new ( 70.99412 , 148.59995 ) , new ( 82.27591 , 138.75620 ) , new ( 78.29964 , - 3.27505 ) , new ( 78.29964 , - 3.27505 ) , new ( - 8.65039 , 47.34995 ) ] ;
32
+ public static IEnumerable < ( double , double ) > Cloudikka_PolylineEncoding_Tuple { get ; } = [ new ( 60.81071 , - 121.40005 ) , new ( 70.05664 , - 38.43130 ) , new ( 37.52379 , - 84.83755 ) , new ( 41.85003 , 26.25620 ) , new ( 68.04709 , 110.63120 ) , new ( 61.48922 , 50.16245 ) , new ( - 4.46018 , - 58.11880 ) , new ( - 32.16061 , - 3.27505 ) , new ( - 50.89185 , - 55.30630 ) , new ( - 28.52070 , 90.94370 ) , new ( 35.26009 , 93.75620 ) , new ( 54.83622 , 128.91245 ) , new ( 1.16022 , 37.50620 ) , new ( - 44.26398 , - 131.24380 ) , new ( - 33.34325 , 154.22495 ) , new ( - 59.65879 , 90.94370 ) , new ( - 62.38215 , 0.94370 ) , new ( 72.32117 , 40.31870 ) , new ( 64.66910 , 2.34995 ) , new ( - 61.04971 , - 84.83755 ) , new ( 77.10238 , - 91.86880 ) , new ( - 72.88859 , - 129.83755 ) , new ( - 69.24987 , - 24.36880 ) , new ( 77.41254 , 119.06870 ) , new ( - 70.69409 , 83.91245 ) , new ( 78.85650 , 75.47495 ) , new ( 26.83989 , 140.16245 ) , new ( - 24.75069 , - 108.74380 ) , new ( 30.53968 , - 145.30630 ) , new ( 79.12503 , 145.78745 ) , new ( - 34.51006 , 133.13120 ) , new ( - 73.29753 , - 60.93130 ) , new ( - 74.08712 , 23.44370 ) , new ( - 76.57404 , 100.78745 ) , new ( - 76.57404 , 100.78745 ) , new ( 39.72082 , 103.59995 ) , new ( 70.99412 , 148.59995 ) , new ( 82.27591 , 138.75620 ) , new ( 78.29964 , - 3.27505 ) , new ( 78.29964 , - 3.27505 ) , new ( - 8.65039 , 47.34995 ) ] ;
33
+
34
+
35
+
36
+ [ Benchmark ]
37
+ public void PolylineDecoder_Decode ( ) {
38
+ ReadOnlySpan < char > polyline = Memory_Polyline . Span ;
39
+ var decoder = new PolylineDecoder ( ) ;
40
+ decoder . Decode ( in polyline ) . Consume ( _consumer ) ;
41
+ }
26
42
27
43
[ Benchmark ]
28
- public Span < Coordinate > Decode ( )
29
- => Decoder
30
- . Decode ( Polyline ) ;
44
+ public void Polyliner_Decode ( ) {
45
+ string polyline = String_Polyline ;
46
+ var polyliner = new Polyliner ( ) ;
47
+ polyliner . Decode ( polyline ) . Consume ( _consumer ) ;
48
+ }
49
+
50
+ [ Benchmark ]
51
+ public void Cloudikka_PolylineEncoding_Decode ( ) {
52
+ string polyline = String_Polyline ;
53
+ var polyliner = new PolylineEncoding ( ) ;
54
+ polyliner . Decode ( polyline ) . Consume ( _consumer ) ;
55
+ }
31
56
32
- public DefaultPolylineEncoder Encoder { get ; } = new DefaultPolylineEncoder ( ) ;
33
57
34
- public IEnumerable < Coordinate > Coordinates { get ; } = [ Coordinate . Create ( 60.81071 , - 121.40005 ) , Coordinate . Create ( 70.05664 , - 38.43130 ) , Coordinate . Create ( 37.52379 , - 84.83755 ) , Coordinate . Create ( 41.85003 , 26.25620 ) , Coordinate . Create ( 68.04709 , 110.63120 ) , Coordinate . Create ( 61.48922 , 50.16245 ) , Coordinate . Create ( - 4.46018 , - 58.11880 ) , Coordinate . Create ( - 32.16061 , - 3.27505 ) , Coordinate . Create ( - 50.89185 , - 55.30630 ) , Coordinate . Create ( - 28.52070 , 90.94370 ) , Coordinate . Create ( 35.26009 , 93.75620 ) , Coordinate . Create ( 54.83622 , 128.91245 ) , Coordinate . Create ( 1.16022 , 37.50620 ) , Coordinate . Create ( - 44.26398 , - 131.24380 ) , Coordinate . Create ( - 33.34325 , 154.22495 ) , Coordinate . Create ( - 59.65879 , 90.94370 ) , Coordinate . Create ( - 62.38215 , 0.94370 ) , Coordinate . Create ( 72.32117 , 40.31870 ) , Coordinate . Create ( 64.66910 , 2.34995 ) , Coordinate . Create ( - 61.04971 , - 84.83755 ) , Coordinate . Create ( 77.10238 , - 91.86880 ) , Coordinate . Create ( - 72.88859 , - 129.83755 ) , Coordinate . Create ( - 69.24987 , - 24.36880 ) , Coordinate . Create ( 77.41254 , 119.06870 ) , Coordinate . Create ( - 70.69409 , 83.91245 ) , Coordinate . Create ( 78.85650 , 75.47495 ) , Coordinate . Create ( 26.83989 , 140.16245 ) , Coordinate . Create ( - 24.75069 , - 108.74380 ) , Coordinate . Create ( 30.53968 , - 145.30630 ) , Coordinate . Create ( 79.12503 , 145.78745 ) , Coordinate . Create ( - 34.51006 , 133.13120 ) , Coordinate . Create ( - 73.29753 , - 60.93130 ) , Coordinate . Create ( - 74.08712 , 23.44370 ) , Coordinate . Create ( - 76.57404 , 100.78745 ) , Coordinate . Create ( - 76.57404 , 100.78745 ) , Coordinate . Create ( 39.72082 , 103.59995 ) , Coordinate . Create ( 70.99412 , 148.59995 ) , Coordinate . Create ( 82.27591 , 138.75620 ) , Coordinate . Create ( 78.29964 , - 3.27505 ) , Coordinate . Create ( 78.29964 , - 3.27505 ) , Coordinate . Create ( - 8.65039 , 47.34995 ) ] ;
58
+ [ Benchmark ]
59
+ public ReadOnlySpan < char > PolylineEncoder_Encode ( ) {
60
+ var encoder = new PolylineEncoder ( ) ;
61
+ return encoder . Encode ( PolylineAlgorithm_Coordinates ) ;
62
+ }
35
63
64
+ [ Benchmark ]
65
+ public string Polyliner_Encode ( ) {
66
+ var polyliner = new Polyliner ( ) ;
67
+ return polyliner . Encode ( PolylinerNet_PolylinePoint ) ;
68
+ }
36
69
37
70
[ Benchmark ]
38
- public Polyline Encode ( )
39
- => Encoder
40
- . Encode ( Coordinates ) ;
71
+ public string Cloudikka_PolylineEncoding_Encode ( ) {
72
+ var polyliner = new PolylineEncoding ( ) ;
73
+ return polyliner . Encode ( Cloudikka_PolylineEncoding_Tuple ) ;
74
+ }
41
75
}
0 commit comments