-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
exclude source generators from ci until stable
- Loading branch information
Showing
3 changed files
with
91 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using Force.DeepCloner; | ||
|
||
namespace FastCloner.Benchmark; | ||
|
||
[RankColumn] | ||
[Orderer(BenchmarkDotNet.Order.SummaryOrderPolicy.FastestToSlowest)] | ||
[MemoryDiagnoser] | ||
public class DictionaryBenchmark | ||
{ | ||
private Dictionary<ComplexKey, string> testData; | ||
|
||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
testData = new Dictionary<ComplexKey, string>(); | ||
|
||
for (int i = 0; i < 1000; i++) | ||
{ | ||
ComplexKey key = new ComplexKey { Id = i, Name = $"Key{i}" }; | ||
testData.Add(key, $"Value{i}"); | ||
} | ||
} | ||
|
||
[Benchmark(Baseline = true)] | ||
public object? FastCloner() | ||
{ | ||
return global::FastCloner.FastCloner.DeepClone(testData); | ||
} | ||
|
||
[Benchmark] | ||
public object? DeepCopier() | ||
{ | ||
return global::DeepCopier.Copier.Copy(testData); | ||
} | ||
|
||
[Benchmark] | ||
public object? DeepCopy() | ||
{ | ||
return global::DeepCopy.DeepCopier.Copy(testData); | ||
} | ||
|
||
[Benchmark] | ||
public object DeepCopyExpression() | ||
{ | ||
return global::DeepCopy.ObjectCloner.Clone(testData); | ||
} | ||
|
||
[Benchmark] | ||
public object? FastDeepCloner() | ||
{ | ||
return global::FastDeepCloner.DeepCloner.Clone(testData); | ||
} | ||
|
||
[Benchmark] | ||
public object? DeepCloner() | ||
{ | ||
return testData.DeepClone(); | ||
} | ||
} | ||
|
||
public class ComplexKey | ||
{ | ||
public int Id { get; set; } | ||
public string Name { get; set; } | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
if (obj is not ComplexKey other) return false; | ||
return Id == other.Id && Name == other.Name; | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return HashCode.Combine(Id, Name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"solution": { | ||
"path": "FastCloner.sln", | ||
"projects": [ | ||
"FastCloner\\FastCloner.csproj", | ||
"FastCloner.Tests\\FastCloner.Tests.csproj", | ||
"FastCloner.Contrib\\FastCloner.Contrib.csproj", | ||
"FastCloner.Benchmark\\FastCloner.Benchmark.csproj" | ||
] | ||
} | ||
} |