Skip to content

Commit 7341c74

Browse files
author
Petr Sramek
committed
refactoring
1 parent 362b836 commit 7341c74

30 files changed

+1787
-1219
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
file_header_template = //\n// Copyright (c) Petr Šrámek. All rights reserved.\n// Licensed under the MIT License. See LICENSE file in the project root for full license information.\n//

benchmarks/PolylineAlgorithm.Benchmarks/PolylineAlgorithm.Benchmarks.csproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@
77
<Nullable>enable</Nullable>
88
<ImplicitUsings>enable</ImplicitUsings>
99
<InvariantGlobalization>true</InvariantGlobalization>
10+
<NeutralLanguage>en</NeutralLanguage>
1011
</PropertyGroup>
1112

1213
<PropertyGroup>
1314
<IsPackable>false</IsPackable>
1415
</PropertyGroup>
1516

1617
<PropertyGroup>
17-
<AnalysisMode>All</AnalysisMode>
18-
<AnalysisLevel>latest</AnalysisLevel>
19-
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
20-
<EnableNETAnalyzers>true</EnableNETAnalyzers>
18+
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
2119
</PropertyGroup>
2220

2321
<ItemGroup>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// Copyright (c) Petr Šrámek. All rights reserved.
3+
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
4+
//
5+
6+
namespace PolylineAlgorithm.Benchmarks {
7+
using BenchmarkDotNet.Attributes;
8+
using BenchmarkDotNet.Engines;
9+
using PolylineAlgorithm.Internal;
10+
11+
[MemoryDiagnoser]
12+
[MarkdownExporter]
13+
public class PolylineDecoderBenchmark {
14+
private Consumer _consumer = new();
15+
16+
public PolylineDecoder Decoder { get; set; }
17+
18+
public static IEnumerable<string> GetPolylines() {
19+
yield return "mz}lHssngJj`gqSnx~lEcovfTnms{Zdy~qQj_deI";
20+
yield return "}vwdGjafcRsvjKi}pxUhsrtCngtcAjjgzEdqvtLrscbKj}nr@wetlUc`nq]}_kfCyrfaK~wluUl`u}|@wa{lUmmuap@va{lU~oihCu||bF`|era@wsnnIjny{DxamaScqxza@dklDf{}kb@mtpeCavfzGqhx`Wyzzkm@jm`d@dba~Pppkg@h}pxU|rtnHp|flA|~xaPuykyN}fhv[h}pxUx~p}Ymx`sZih~iB{edwB";
21+
yield return "}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";
22+
}
23+
24+
[GlobalSetup]
25+
public void Setup() {
26+
Decoder = new PolylineDecoder();
27+
}
28+
29+
[Benchmark]
30+
[ArgumentsSource(nameof(GetPolylines))]
31+
public IEnumerable<(double, double)> Decode(string polyline) => Decoder
32+
.Decode(polyline);
33+
}
34+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// Copyright (c) Petr Šrámek. All rights reserved.
3+
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
4+
//
5+
6+
namespace PolylineAlgorithm.Benchmarks {
7+
using BenchmarkDotNet.Attributes;
8+
using BenchmarkDotNet.Engines;
9+
using PolylineAlgorithm.Internal;
10+
11+
[MemoryDiagnoser]
12+
[MarkdownExporter]
13+
public class PolylineEncoderBenchmark {
14+
private Consumer _consumer = new();
15+
16+
public PolylineEncoder Encoder { get; set; }
17+
18+
public IEnumerable<IEnumerable<(double, double)>> GetCoordinates() {
19+
yield return new[] { (49.47383, 59.06250), (-58.37407, 25.31250), (52.99363, -120.93750), (-44.49024, -174.37500) };
20+
yield return new[] { (42.88895, -100.30630), (44.91513, 19.22495), (20.40244, 7.97495), (-15.52130, -63.74380), (-78.95116, -72.18130), (38.63072, 88.13120), (60.81071, 151.41245), (-58.20769, -173.43130), (59.40939, 83.91245), (-58.20769, 61.41245), (-20.86278, -119.99380), (34.10374, -150.93130), (-71.15367, 31.88120), (-72.04138, -153.74380), (-49.99635, -107.33755), (76.12614, 135.94370), (70.05664, 41.72495), (63.43879, -77.80630), (13.68456, -90.46255), (-75.90519, -7.49380), (74.71112, -127.02505), (-66.61109, 17.81870), (-49.08384, 37.50620) };
21+
yield return new[] { (60.81071, -121.40005), (70.05664, -38.43130), (37.52379, -84.83755), (41.85003, 26.25620), (68.04709, 110.63120), (61.48922, 50.16245), (-4.46018, -58.11880), (-32.16061, -3.27505), (-50.89185, -55.30630), (-28.52070, 90.94370), (35.26009, 93.75620), (54.83622, 128.91245), (1.16022, 37.50620), (-44.26398, -131.24380), (-33.34325, 154.22495), (-59.65879, 90.94370), (-62.38215, 0.94370), (72.32117, 40.31870), (64.66910, 2.34995), (-61.04971, -84.83755), (77.10238, -91.86880), (-72.88859, -129.83755), (-69.24987, -24.36880), (77.41254, 119.06870), (-70.69409, 83.91245), (78.85650, 75.47495), (26.83989, 140.16245), (-24.75069, -108.74380), (30.53968, -145.30630), (79.12503, 145.78745), (-34.51006, 133.13120), (-73.29753, -60.93130), (-74.08712, 23.44370), (-76.57404, 100.78745), (-76.57404, 100.78745), (39.72082, 103.59995), (70.99412, 148.59995), (82.27591, 138.75620), (78.29964, -3.27505), (78.29964, -3.27505), (-8.65039, 47.34995) };
22+
}
23+
24+
[GlobalSetup]
25+
public void Setup() {
26+
Encoder = new PolylineEncoder();
27+
}
28+
29+
[Benchmark]
30+
[ArgumentsSource(nameof(GetCoordinates))]
31+
public void Encode(IEnumerable<(double, double)> coordinates) => Encoder
32+
.Encode(coordinates)
33+
.Consume(_consumer);
34+
}
35+
}

benchmarks/PolylineAlgorithm.Benchmarks/PolylineEncodingBenchmark.cs

Lines changed: 0 additions & 42 deletions
This file was deleted.

benchmarks/PolylineAlgorithm.Benchmarks/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace PolylineAlgorithm.Benchmarks {
99
internal class Program {
1010
static void Main(string[] _) {
1111
BenchmarkRunner
12-
.Run<PolylineEncodingBenchmark>();
12+
.Run<PolylineEncoderBenchmark>();
1313
}
1414
}
1515
}

0 commit comments

Comments
 (0)