-
Notifications
You must be signed in to change notification settings - Fork 15
move to TUnit, fix thread safety edge cases #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e674bf4
move to TUnit, fix thread safety edge cases
lofcz bb57594
fix ci
lofcz 39acf31
Update dotnet.yml
lofcz 2df92e9
fix
lofcz 12e202a
fix
lofcz d3bc7f6
fix
lofcz d49d4ab
remove old props
lofcz 0162be2
fix
lofcz 20bba9c
dry
lofcz eb09235
readme
lofcz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net10.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <ProjectReference Include="..\src\FastCloner\FastCloner.csproj" /> | ||
| </ItemGroup> | ||
| </Project> |
This file contains hidden or 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,34 @@ | ||
| using System.Diagnostics; | ||
| using FastCloner; | ||
|
|
||
| var results = new List<(string Name, double Ms, double NsPerOp)>(); | ||
| Measure("SmallObject x100000", CreateSmallObject(), 2000, 100000, static x => FastCloner.FastCloner.DeepClone((SmallObject)x)!); | ||
| Measure("StringArray1000 x20000", CreateStringArray(1000), 500, 20000, static x => FastCloner.FastCloner.DeepClone((string[])x)!); | ||
| Measure("Dictionary50 x5000", CreateDictionary(50), 200, 5000, static x => FastCloner.FastCloner.DeepClone((Dictionary<string, SmallObject>)x)!); | ||
| foreach (var (name, ms, nsPerOp) in results) | ||
| Console.WriteLine($"{name}|{ms:F2}|{nsPerOp:F1}"); | ||
|
|
||
| void Measure(string name, object value, int warmup, int iterations, Func<object, object> clone) | ||
| { | ||
| for (var i = 0; i < warmup; i++) _ = clone(value); | ||
| GC.Collect(); | ||
| GC.WaitForPendingFinalizers(); | ||
| GC.Collect(); | ||
| var sw = Stopwatch.StartNew(); | ||
| for (var i = 0; i < iterations; i++) _ = clone(value); | ||
| sw.Stop(); | ||
| results.Add((name, sw.Elapsed.TotalMilliseconds, sw.Elapsed.TotalMilliseconds * 1_000_000d / iterations)); | ||
| } | ||
|
|
||
| static SmallObject CreateSmallObject() => new() { Id = 123, Name = "small-object-name", CreatedAt = new DateTime(2025, 1, 1, 0, 0, 0, DateTimeKind.Utc), IsActive = true, Score = 42.5 }; | ||
| static string[] CreateStringArray(int count) { var arr = new string[count]; for (var i = 0; i < count; i++) arr[i] = $"value-{i}"; return arr; } | ||
| static Dictionary<string, SmallObject> CreateDictionary(int count) { var dict = new Dictionary<string, SmallObject>(count); for (var i = 0; i < count; i++) dict[$"key-{i}"] = new SmallObject { Id = i, Name = $"item-{i}", CreatedAt = new DateTime(2025, 1, 1).AddMinutes(i), IsActive = (i & 1) == 0, Score = i * 1.25 }; return dict; } | ||
|
|
||
| public sealed class SmallObject | ||
| { | ||
| public int Id { get; set; } | ||
| public string Name { get; set; } = string.Empty; | ||
| public DateTime CreatedAt { get; set; } | ||
| public bool IsActive { get; set; } | ||
| public double Score { get; set; } | ||
| } |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workflow sets
BASELINE_BRANCHtonext, but the benchmark CI README describes baseline artifacts and slow-path cloning coming frommaster. Please align the workflow/env var with the documented baseline branch (or update the README to match the intended branch).