Skip to content

Commit 8b681ba

Browse files
committed
Rework benchmarking
1 parent c51327a commit 8b681ba

10 files changed

Lines changed: 170 additions & 186 deletions

File tree

.github/workflows/dotnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
with:
5858
name: Benchmark.Net Benchmark
5959
tool: 'benchmarkdotnet'
60-
output-file-path: tests/DynamoDBGenerator.SourceGenerator.Benchmarks/DynamoDBGenerator.SourceGenerator.Benchmarks.Benchmarks.Marshalling.TemporalBenchmarks-report-full-compressed.json
60+
output-file-path: tests/DynamoDBGenerator.SourceGenerator.Benchmarks/BenchmarkDotNet.Artifacts/results/DynamoDBGenerator.SourceGenerator.Benchmarks.Benchmarks.Marshalling.TemporalBenchmarks-report-full-compressed.json
6161
github-token: ${{ secrets.GITHUB_TOKEN }}
6262
auto-push: true
6363
# Show alert with commit comment on detecting possible performance regression

tests/DynamoDBGenerator.SourceGenerator.Benchmarks/Benchmarks/Marshalling/DynamoDbMarshallerBenchmarkHelper.cs renamed to tests/DynamoDBGenerator.SourceGenerator.Benchmarks/Benchmarks/Marshalling/BenchmarkHelper.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
using Amazon.DynamoDBv2.Model;
33
using AutoFixture;
44

5-
namespace DynamoDBGenerator.SourceGenerator.Benchmarks.Benchmarks.Marshalling.Temporal;
5+
namespace DynamoDBGenerator.SourceGenerator.Benchmarks.Benchmarks.Marshalling;
66

77
public class DynamoDbMarshallerBenchmarkHelper<T, T2, T3, T4> where T4 : IAttributeExpressionValueTracker<T2>
88
where T3 : IAttributeExpressionNameTracker
99
{
1010
private readonly IDynamoDBMarshaller<T, T2, T3, T4> _marshaller;
1111
private readonly T _element;
12-
private readonly Dictionary<string, AttributeValue> _attributevalues;
12+
private readonly Dictionary<string, AttributeValue> _attributeValues;
1313

1414
public DynamoDbMarshallerBenchmarkHelper(IDynamoDBMarshaller<T, T2, T3, T4> marshaller)
1515
{
1616
_marshaller = marshaller;
1717
_element = SetupFixture().Create<T>();
18-
_attributevalues = marshaller.Marshall(_element);
18+
_attributeValues = marshaller.Marshall(_element);
1919
}
2020

2121
[MethodImpl(MethodImplOptions.AggressiveInlining)]
22-
public T Unmarshall() => _marshaller.Unmarshall(_attributevalues);
22+
public T Unmarshall() => _marshaller.Unmarshall(_attributeValues);
2323

2424
[MethodImpl(MethodImplOptions.AggressiveInlining)]
2525
public Dictionary<string, AttributeValue> Marshall() => _marshaller.Marshall(_element);
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using Amazon.DynamoDBv2.Model;
2+
using BenchmarkDotNet.Attributes;
3+
using DynamoDBGenerator.Attributes;
4+
5+
namespace DynamoDBGenerator.SourceGenerator.Benchmarks.Benchmarks.Marshalling;
6+
7+
[DynamoDBMarshaller(EntityType = typeof(Container<Dictionary<string, int>>), AccessName = "DictionaryMarshaller")]
8+
[DynamoDBMarshaller(EntityType = typeof(Container<HashSet<string>>), AccessName = "StringHashSetMarshaller")]
9+
[DynamoDBMarshaller(EntityType = typeof(Container<List<string>>), AccessName = "ListMarshaller")]
10+
[DynamoDBMarshaller(EntityType = typeof(Container<HashSet<int>>), AccessName = "IntHashSetMarshaller")]
11+
[DynamoDBMarshaller(EntityType = typeof(Container<List<KeyValuePair<string, int>>>), AccessName = "KeyValuePairListMarshaller")]
12+
public partial class CollectionBenchmarks
13+
{
14+
private readonly DynamoDbMarshallerBenchmarkHelper<Container<Dictionary<string, int>>, Container<Dictionary<string, int>>, ContainerDictionarystringintNames, ContainerDictionarystringintValues> _dictionary = DictionaryMarshaller.ToBenchmarkHelper();
15+
private readonly DynamoDbMarshallerBenchmarkHelper<Container<HashSet<string>>, Container<HashSet<string>>, ContainerHashSetstringNames, ContainerHashSetstringValues> _stringHashSet = StringHashSetMarshaller.ToBenchmarkHelper();
16+
private readonly DynamoDbMarshallerBenchmarkHelper<Container<List<string>>, Container<List<string>>, ContainerListstringNames, ContainerListstringValues> _stringList = ListMarshaller.ToBenchmarkHelper();
17+
private readonly DynamoDbMarshallerBenchmarkHelper<Container<HashSet<int>>, Container<HashSet<int>>, ContainerHashSetintNames, ContainerHashSetintValues> _intHashSet = IntHashSetMarshaller.ToBenchmarkHelper();
18+
private readonly DynamoDbMarshallerBenchmarkHelper<Container<List<KeyValuePair<string, int>>>, Container<List<KeyValuePair<string, int>>>, ContainerListKeyValuePairstringintNames, ContainerListKeyValuePairstringintValues> _keyValuePairList = KeyValuePairListMarshaller.ToBenchmarkHelper();
19+
20+
[Benchmark]
21+
public Container<Dictionary<string, int>> Unmarshall_Dictionary() => _dictionary.Unmarshall();
22+
23+
[Benchmark]
24+
public Dictionary<string, AttributeValue> Marshall_Dictionary() => _dictionary.Marshall();
25+
26+
[Benchmark]
27+
public Container<HashSet<string>> Unmarshall_StringHashSet() => _stringHashSet.Unmarshall();
28+
29+
[Benchmark]
30+
public Dictionary<string, AttributeValue> Marshall_StringHashSet() => _stringHashSet.Marshall();
31+
32+
[Benchmark]
33+
public Container<List<string>> Unmarshall_StringList() => _stringList.Unmarshall();
34+
35+
[Benchmark]
36+
public Dictionary<string, AttributeValue> Marshall_StringList() => _stringList.Marshall();
37+
38+
[Benchmark]
39+
public Container<HashSet<int>> Unmarshall_IntHashSet() => _intHashSet.Unmarshall();
40+
41+
[Benchmark]
42+
public Dictionary<string, AttributeValue> Marshall_IntHashSet() => _intHashSet.Marshall();
43+
44+
[Benchmark]
45+
public Container<List<KeyValuePair<string,int>>> Unmarshall_KeyValuePairList() => _keyValuePairList.Unmarshall();
46+
47+
[Benchmark]
48+
public Dictionary<string, AttributeValue> Marshall_KeyValuePairList() => _keyValuePairList.Marshall();
49+
}

tests/DynamoDBGenerator.SourceGenerator.Benchmarks/Benchmarks/Marshalling/Collections/Benchmarks.cs

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

tests/DynamoDBGenerator.SourceGenerator.Benchmarks/Benchmarks/Marshalling/Primitive/Benchmarks.cs

Lines changed: 0 additions & 67 deletions
This file was deleted.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
using Amazon.DynamoDBv2.Model;
2+
using BenchmarkDotNet.Attributes;
3+
using DynamoDBGenerator.Attributes;
4+
5+
namespace DynamoDBGenerator.SourceGenerator.Benchmarks.Benchmarks.Marshalling;
6+
7+
[DynamoDBMarshaller(EntityType = typeof(Container<bool>), AccessName = "BooleanMarshaller")]
8+
[DynamoDBMarshaller(EntityType = typeof(Container<char>), AccessName = "CharMarshaller")]
9+
[DynamoDBMarshaller(EntityType = typeof(Container<int>), AccessName = "Int32Marshaller")]
10+
[DynamoDBMarshaller(EntityType = typeof(Container<long>), AccessName = "Int64Marshaller")]
11+
[DynamoDBMarshaller(EntityType = typeof(Container<string>), AccessName = "StringMarshaller")]
12+
[DynamoDBMarshaller(EntityType = typeof(Container<uint>), AccessName = "UInt32Marshaller")]
13+
[DynamoDBMarshaller(EntityType = typeof(Container<ulong>), AccessName = "UInt64Marshaller")]
14+
[DynamoDBMarshaller(EntityType = typeof(Container<Guid>), AccessName = "GuidMarshaller")]
15+
[DynamoDBMarshaller(EntityType = typeof(Container<DayOfWeek>), AccessName = "EnumMarshaller")]
16+
[DynamoDBMarshaller(EntityType = typeof(Container<double>), AccessName = "DoubleMarshaller")]
17+
public partial class PrimitiveBenchmarks
18+
{
19+
private readonly DynamoDbMarshallerBenchmarkHelper<Container<bool>, Container<bool>, ContainerboolNames, ContainerboolValues> _bool = BooleanMarshaller.ToBenchmarkHelper();
20+
private readonly DynamoDbMarshallerBenchmarkHelper<Container<char>, Container<char>, ContainercharNames, ContainercharValues> _char = CharMarshaller.ToBenchmarkHelper();
21+
private readonly DynamoDbMarshallerBenchmarkHelper<Container<int>, Container<int>, ContainerintNames, ContainerintValues> _int = Int32Marshaller.ToBenchmarkHelper();
22+
private readonly DynamoDbMarshallerBenchmarkHelper<Container<long>, Container<long>, ContainerlongNames, ContainerlongValues> _long = Int64Marshaller.ToBenchmarkHelper();
23+
private readonly DynamoDbMarshallerBenchmarkHelper<Container<string>, Container<string>, ContainerstringNames, ContainerstringValues> _string = StringMarshaller.ToBenchmarkHelper();
24+
private readonly DynamoDbMarshallerBenchmarkHelper<Container<uint>, Container<uint>, ContaineruintNames, ContaineruintValues> _uint = UInt32Marshaller.ToBenchmarkHelper();
25+
private readonly DynamoDbMarshallerBenchmarkHelper<Container<ulong>, Container<ulong>, ContainerulongNames, ContainerulongValues> _ulong = UInt64Marshaller.ToBenchmarkHelper();
26+
private readonly DynamoDbMarshallerBenchmarkHelper<Container<Guid>, Container<Guid>, ContainerGuidNames, ContainerGuidValues> _guid = GuidMarshaller.ToBenchmarkHelper();
27+
private readonly DynamoDbMarshallerBenchmarkHelper<Container<DayOfWeek>, Container<DayOfWeek>, ContainerDayOfWeekNames, ContainerDayOfWeekValues> _enum = EnumMarshaller.ToBenchmarkHelper();
28+
private readonly DynamoDbMarshallerBenchmarkHelper<Container<double>, Container<double>, ContainerdoubleNames, ContainerdoubleValues> _double = DoubleMarshaller.ToBenchmarkHelper();
29+
30+
[Benchmark]
31+
public Container<bool> Unmarshall_Bool() => _bool.Unmarshall();
32+
33+
[Benchmark]
34+
public Dictionary<string, AttributeValue> Marshall_Bool() => _bool.Marshall();
35+
36+
[Benchmark]
37+
public Container<char> Unmarshall_Char() => _char.Unmarshall();
38+
39+
[Benchmark]
40+
public Dictionary<string, AttributeValue> Marshall_Char() => _char.Marshall();
41+
42+
[Benchmark]
43+
public Container<int> Unmarshall_Int32() => _int.Unmarshall();
44+
45+
[Benchmark]
46+
public Dictionary<string, AttributeValue> Marshall_Int() => _int.Marshall();
47+
48+
[Benchmark]
49+
public Container<long> Unmarshall_Int64() => _long.Unmarshall();
50+
51+
[Benchmark]
52+
public Dictionary<string, AttributeValue> Marshall_Int64() => _long.Marshall();
53+
54+
[Benchmark]
55+
public Container<string> Unmarshall_String() => _string.Unmarshall();
56+
57+
[Benchmark]
58+
public Dictionary<string, AttributeValue> Marshall_String() => _string.Marshall();
59+
60+
[Benchmark]
61+
public Container<uint> Unmarshall_UInt32() => _uint.Unmarshall();
62+
63+
[Benchmark]
64+
public Dictionary<string, AttributeValue> Marshall_UInt32() => _uint.Marshall();
65+
66+
[Benchmark]
67+
public Container<ulong> Unmarshall_UInt64() => _ulong.Unmarshall();
68+
69+
[Benchmark]
70+
public Dictionary<string, AttributeValue> Marshall_Uint64() => _ulong.Marshall();
71+
72+
[Benchmark]
73+
public Container<Guid> Unmarshall_Guid() => _guid.Unmarshall();
74+
75+
[Benchmark]
76+
public Dictionary<string, AttributeValue> Marshall_Guid() => _guid.Marshall();
77+
78+
[Benchmark]
79+
public Container<DayOfWeek> Unmarshall_Enum() => _enum.Unmarshall();
80+
81+
[Benchmark]
82+
public Dictionary<string, AttributeValue> Marshall_Enum() => _enum.Marshall();
83+
84+
[Benchmark]
85+
public Container<double> Unmarshall_Double() => _double.Unmarshall();
86+
87+
[Benchmark]
88+
public Dictionary<string, AttributeValue> Marshall_Double() => _double.Marshall();
89+
}

tests/DynamoDBGenerator.SourceGenerator.Benchmarks/Benchmarks/Marshalling/TemporalBenchmarks.cs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,18 @@
22
using BenchmarkDotNet.Attributes;
33
using DynamoDBGenerator.Attributes;
44

5-
namespace DynamoDBGenerator.SourceGenerator.Benchmarks.Benchmarks.Marshalling.Temporal;
5+
namespace DynamoDBGenerator.SourceGenerator.Benchmarks.Benchmarks.Marshalling;
66

77
[DynamoDBMarshaller(EntityType = typeof(Container<DateTime>), AccessName = "DateTimeMarshaller")]
88
[DynamoDBMarshaller(EntityType = typeof(Container<DateTimeOffset>), AccessName = "DateTimeOffsetMarshaller")]
99
[DynamoDBMarshaller(EntityType = typeof(Container<DateOnly>), AccessName = "DateOnlyMarshaller")]
1010
[DynamoDBMarshaller(EntityType = typeof(Container<TimeOnly>), AccessName = "TimeOnlyMarshaller")]
11-
public sealed partial class TemporalBenchmarks
11+
public partial class TemporalBenchmarks
1212
{
13-
private readonly DynamoDbMarshallerBenchmarkHelper<Container<DateTime>, Container<DateTime>, ContainerDateTimeNames,
14-
ContainerDateTimeValues> _dateTime = DateTimeMarshaller.ToBenchmarkHelper();
15-
16-
private readonly DynamoDbMarshallerBenchmarkHelper<Container<DateTimeOffset>, Container<DateTimeOffset>,
17-
ContainerDateTimeOffsetNames, ContainerDateTimeOffsetValues> _dateTimeOffset =
18-
DateTimeOffsetMarshaller.ToBenchmarkHelper();
19-
20-
private readonly DynamoDbMarshallerBenchmarkHelper<Container<DateOnly>, Container<DateOnly>, ContainerDateOnlyNames,
21-
ContainerDateOnlyValues> _dateOnly =
22-
DateOnlyMarshaller.ToBenchmarkHelper();
23-
24-
private readonly DynamoDbMarshallerBenchmarkHelper<Container<TimeOnly>, Container<TimeOnly>, ContainerTimeOnlyNames,
25-
ContainerTimeOnlyValues> _timeOnly =
26-
TimeOnlyMarshaller.ToBenchmarkHelper();
27-
13+
private readonly DynamoDbMarshallerBenchmarkHelper<Container<DateTime>, Container<DateTime>, ContainerDateTimeNames, ContainerDateTimeValues> _dateTime = DateTimeMarshaller.ToBenchmarkHelper();
14+
private readonly DynamoDbMarshallerBenchmarkHelper<Container<DateTimeOffset>, Container<DateTimeOffset>, ContainerDateTimeOffsetNames, ContainerDateTimeOffsetValues> _dateTimeOffset = DateTimeOffsetMarshaller.ToBenchmarkHelper();
15+
private readonly DynamoDbMarshallerBenchmarkHelper<Container<DateOnly>, Container<DateOnly>, ContainerDateOnlyNames, ContainerDateOnlyValues> _dateOnly = DateOnlyMarshaller.ToBenchmarkHelper();
16+
private readonly DynamoDbMarshallerBenchmarkHelper<Container<TimeOnly>, Container<TimeOnly>, ContainerTimeOnlyNames, ContainerTimeOnlyValues> _timeOnly = TimeOnlyMarshaller.ToBenchmarkHelper();
2817

2918
[Benchmark]
3019
public Container<TimeOnly> Unmarshall_TimeOnly() => _timeOnly.Unmarshall();

tests/DynamoDBGenerator.SourceGenerator.Benchmarks/Benchmarks/SG_BenchMarker.cs

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

0 commit comments

Comments
 (0)