Skip to content

Commit bd607ec

Browse files
author
Petr Sramek
committed
reorganized benchmark classes
1 parent 0d392fb commit bd607ec

File tree

2 files changed

+46
-28
lines changed

2 files changed

+46
-28
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// Copyright (c) Pete Sramek. 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+
8+
using BenchmarkDotNet.Attributes;
9+
using BenchmarkDotNet.Engines;
10+
using BenchmarkDotNet.Order;
11+
using Cloudikka.PolylineAlgorithm.Encoding;
12+
using PolylineAlgorithm;
13+
using PolylinerNet;
14+
using System.Collections.Generic;
15+
16+
[RankColumn]
17+
[MemoryDiagnoser]
18+
[Orderer(SummaryOrderPolicy.Default)]
19+
public class DecodeBenchmark {
20+
private readonly Consumer _consumer = new();
21+
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";
22+
public static ReadOnlyMemory<char> Memory_Polyline { get; } = String_Polyline.AsMemory();
23+
24+
25+
[Benchmark]
26+
public void PolylineDecoder_Decode() {
27+
ReadOnlySpan<char> polyline = Memory_Polyline.Span;
28+
var decoder = new PolylineDecoder();
29+
decoder.Decode(in polyline).Consume(_consumer);
30+
}
31+
32+
[Benchmark]
33+
public void Polyliner_Decode() {
34+
string polyline = String_Polyline;
35+
var polyliner = new Polyliner();
36+
polyliner.Decode(polyline).Consume(_consumer);
37+
}
38+
39+
[Benchmark]
40+
public void Cloudikka_PolylineEncoding_Decode() {
41+
string polyline = String_Polyline;
42+
var polyliner = new PolylineEncoding();
43+
polyliner.Decode(polyline).Consume(_consumer);
44+
}
45+
}

benchmarks/PolylineAlgorithm.Benchmarks/PolylineBenchmark.cs renamed to benchmarks/PolylineAlgorithm.Benchmarks/EncodeBenchmark.cs

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,39 +16,12 @@ namespace PolylineAlgorithm.Benchmarks;
1616
[RankColumn]
1717
[MemoryDiagnoser]
1818
[Orderer(SummaryOrderPolicy.Default)]
19-
public class PolylineBenchmark {
20-
private readonly Consumer _consumer = new();
21-
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";
22-
public static ReadOnlyMemory<char> Memory_Polyline { get; } = String_Polyline.AsMemory();
23-
19+
public class EncodeBenchmark {
2420
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)];
2521
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)];
2622
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)];
2723

2824

29-
30-
[Benchmark]
31-
public void PolylineDecoder_Decode() {
32-
ReadOnlySpan<char> polyline = Memory_Polyline.Span;
33-
var decoder = new PolylineDecoder();
34-
decoder.Decode(in polyline).Consume(_consumer);
35-
}
36-
37-
[Benchmark]
38-
public void Polyliner_Decode() {
39-
string polyline = String_Polyline;
40-
var polyliner = new Polyliner();
41-
polyliner.Decode(polyline).Consume(_consumer);
42-
}
43-
44-
[Benchmark]
45-
public void Cloudikka_PolylineEncoding_Decode() {
46-
string polyline = String_Polyline;
47-
var polyliner = new PolylineEncoding();
48-
polyliner.Decode(polyline).Consume(_consumer);
49-
}
50-
51-
5225
[Benchmark]
5326
public ReadOnlySpan<char> PolylineEncoder_Encode() {
5427
var encoder = new PolylineEncoder();

0 commit comments

Comments
 (0)