-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6bffad8
commit 1bcd83b
Showing
37 changed files
with
1,394 additions
and
1,343 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="CSharpInteractive" Version="1.0.7" /> | ||
<PackageReference Include="CSharpInteractive" Version="1.0.7"/> | ||
</ItemGroup> | ||
|
||
</Project> |
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
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 |
---|---|---|
@@ -1,56 +1,56 @@ | ||
// ReSharper disable UnusedVariable | ||
namespace Immutype.Benchmark | ||
{ | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Order; | ||
// ReSharper disable WithExpressionModifiesAllMembers | ||
namespace Immutype.Benchmark; | ||
|
||
[Target] | ||
public record PersonRecordWithFourProperties(string? Name, int Age, string? LastName, bool HasPassport); | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Order; | ||
|
||
[Target] | ||
public readonly record struct PersonRecordStructWithFourProperties(string? Name, int Age, string? LastName, bool HasPassport); | ||
[Target] | ||
public record PersonRecordWithFourProperties(string? Name, int Age, string? LastName, bool HasPassport); | ||
|
||
[MemoryDiagnoser] | ||
[Orderer(SummaryOrderPolicy.FastestToSlowest)] | ||
public class RecordWithFourProperties | ||
{ | ||
private readonly PersonRecordWithFourProperties _john = new("John", 15, "Smith", false); | ||
private readonly PersonRecordStructWithFourProperties _johnStruct = new("John", 15, "Smith", false); | ||
[Target] | ||
public readonly record struct PersonRecordStructWithFourProperties(string? Name, int Age, string? LastName, bool HasPassport); | ||
|
||
[Benchmark] | ||
public void WithForRecord() | ||
{ | ||
var david = _john with | ||
{ | ||
Name = "David", | ||
Age = 17, | ||
LastName = "Black", | ||
HasPassport = true | ||
}; | ||
} | ||
|
||
[Benchmark] | ||
public void WithForRecordStruct() | ||
{ | ||
var david = _johnStruct with | ||
{ | ||
Name = "David", | ||
Age = 17, | ||
LastName = "Black", | ||
HasPassport = true | ||
}; | ||
} | ||
|
||
[Benchmark] | ||
public void ImmutypeForRecord() | ||
[MemoryDiagnoser] | ||
[Orderer(SummaryOrderPolicy.FastestToSlowest)] | ||
public class RecordWithFourProperties | ||
{ | ||
private readonly PersonRecordWithFourProperties _john = new("John", 15, "Smith", false); | ||
private readonly PersonRecordStructWithFourProperties _johnStruct = new("John", 15, "Smith", false); | ||
|
||
[Benchmark] | ||
public void WithForRecord() | ||
{ | ||
var david = _john with | ||
{ | ||
var david = _john.WithName("David").WithAge(17).WithLastName("Black").WithHasPassport(true); | ||
} | ||
Name = "David", | ||
Age = 17, | ||
LastName = "Black", | ||
HasPassport = true | ||
}; | ||
} | ||
|
||
[Benchmark] | ||
public void ImmutypeForRecordStruct() | ||
[Benchmark] | ||
public void WithForRecordStruct() | ||
{ | ||
var david = _johnStruct with | ||
{ | ||
var david = _johnStruct.WithName("David").WithAge(17).WithLastName("Black").WithHasPassport(true); | ||
} | ||
Name = "David", | ||
Age = 17, | ||
LastName = "Black", | ||
HasPassport = true | ||
}; | ||
} | ||
|
||
[Benchmark] | ||
public void ImmutypeForRecord() | ||
{ | ||
var david = _john.WithName("David").WithAge(17).WithLastName("Black").WithHasPassport(true); | ||
} | ||
|
||
[Benchmark] | ||
public void ImmutypeForRecordStruct() | ||
{ | ||
var david = _johnStruct.WithName("David").WithAge(17).WithLastName("Black").WithHasPassport(true); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,50 +1,51 @@ | ||
// ReSharper disable UnusedVariable | ||
namespace Immutype.Benchmark | ||
{ | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Order; | ||
// ReSharper disable WithExpressionModifiesAllMembers | ||
// ReSharper disable NotAccessedPositionalProperty.Global | ||
namespace Immutype.Benchmark; | ||
|
||
[Target] | ||
public record PersonRecordWithOneProperty(string? Name); | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Order; | ||
|
||
[Target] | ||
public readonly record struct PersonRecordStructWithOneProperty(string? Name); | ||
[Target] | ||
public record PersonRecordWithOneProperty(string? Name); | ||
|
||
[MemoryDiagnoser] | ||
[Orderer(SummaryOrderPolicy.FastestToSlowest)] | ||
public class RecordWithOneProperty | ||
{ | ||
private readonly PersonRecordWithOneProperty _john = new("John"); | ||
private readonly PersonRecordStructWithOneProperty _johnStruct = new("John"); | ||
[Target] | ||
public readonly record struct PersonRecordStructWithOneProperty(string? Name); | ||
|
||
[Benchmark] | ||
public void WithForRecord() | ||
{ | ||
var david = _john with | ||
{ | ||
Name = "David" | ||
}; | ||
} | ||
|
||
[Benchmark] | ||
public void WithForRecordStruct() | ||
{ | ||
var david = _johnStruct with | ||
{ | ||
Name = "David" | ||
}; | ||
} | ||
|
||
[Benchmark] | ||
public void ImmutypeForRecord() | ||
[MemoryDiagnoser] | ||
[Orderer(SummaryOrderPolicy.FastestToSlowest)] | ||
public class RecordWithOneProperty | ||
{ | ||
private readonly PersonRecordWithOneProperty _john = new("John"); | ||
private readonly PersonRecordStructWithOneProperty _johnStruct = new("John"); | ||
|
||
[Benchmark] | ||
public void WithForRecord() | ||
{ | ||
var david = _john with | ||
{ | ||
var david = _john.WithName("David"); | ||
} | ||
Name = "David" | ||
}; | ||
} | ||
|
||
[Benchmark] | ||
public void ImmutypeForRecordStruct() | ||
[Benchmark] | ||
public void WithForRecordStruct() | ||
{ | ||
var david = _johnStruct with | ||
{ | ||
var david = _johnStruct.WithName("David"); | ||
} | ||
Name = "David" | ||
}; | ||
} | ||
|
||
[Benchmark] | ||
public void ImmutypeForRecord() | ||
{ | ||
var david = _john.WithName("David"); | ||
} | ||
|
||
[Benchmark] | ||
public void ImmutypeForRecordStruct() | ||
{ | ||
var david = _johnStruct.WithName("David"); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,52 +1,52 @@ | ||
// ReSharper disable UnusedVariable | ||
namespace Immutype.Benchmark | ||
{ | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Order; | ||
// ReSharper disable WithExpressionModifiesAllMembers | ||
namespace Immutype.Benchmark; | ||
|
||
[Target] | ||
public record PersonRecordWithTwoProperties(string? Name, int Age); | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Order; | ||
|
||
[Target] | ||
public readonly record struct PersonRecordStructWithTwoProperties(string? Name, int Age); | ||
[Target] | ||
public record PersonRecordWithTwoProperties(string? Name, int Age); | ||
|
||
[MemoryDiagnoser] | ||
[Orderer(SummaryOrderPolicy.FastestToSlowest)] | ||
public class RecordWithTwoProperties | ||
{ | ||
private readonly PersonRecordWithTwoProperties _john = new("John", 15); | ||
private readonly PersonRecordStructWithTwoProperties _johnStruct = new("John", 15); | ||
[Target] | ||
public readonly record struct PersonRecordStructWithTwoProperties(string? Name, int Age); | ||
|
||
[Benchmark] | ||
public void WithForRecord() | ||
{ | ||
var david = _john with | ||
{ | ||
Name = "David", | ||
Age = 17 | ||
}; | ||
} | ||
|
||
[Benchmark] | ||
public void WithForRecordStruct() | ||
{ | ||
var david = _johnStruct with | ||
{ | ||
Name = "David", | ||
Age = 17 | ||
}; | ||
} | ||
|
||
[Benchmark] | ||
public void ImmutypeForRecord() | ||
[MemoryDiagnoser] | ||
[Orderer(SummaryOrderPolicy.FastestToSlowest)] | ||
public class RecordWithTwoProperties | ||
{ | ||
private readonly PersonRecordWithTwoProperties _john = new("John", 15); | ||
private readonly PersonRecordStructWithTwoProperties _johnStruct = new("John", 15); | ||
|
||
[Benchmark] | ||
public void WithForRecord() | ||
{ | ||
var david = _john with | ||
{ | ||
var david = _john.WithName("David").WithAge(17); | ||
} | ||
Name = "David", | ||
Age = 17 | ||
}; | ||
} | ||
|
||
[Benchmark] | ||
public void ImmutypeForRecordStruct() | ||
[Benchmark] | ||
public void WithForRecordStruct() | ||
{ | ||
var david = _johnStruct with | ||
{ | ||
var david = _johnStruct.WithName("David").WithAge(17); | ||
} | ||
Name = "David", | ||
Age = 17 | ||
}; | ||
} | ||
|
||
[Benchmark] | ||
public void ImmutypeForRecord() | ||
{ | ||
var david = _john.WithName("David").WithAge(17); | ||
} | ||
|
||
[Benchmark] | ||
public void ImmutypeForRecordStruct() | ||
{ | ||
var david = _johnStruct.WithName("David").WithAge(17); | ||
} | ||
} |
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
Oops, something went wrong.