Skip to content

Commit f2a1e7a

Browse files
authored
Investigate Clone performance (#4863)
* Add ISerializationCloner for efficient object cloning Introduced the ISerializationCloner interface to support efficient object cloning via serialization. Updated MobileFormatter to implement this interface and provided a Clone method using DTO serialization. Refactored ObjectCloner to use the new interface when available, with fallback to the previous approach. Removed unused usings in MobileFormatter.cs. * added benchmark * Remove Nerdbank.GitVersioning update from benchmarks project Removed the <ItemGroup> that updated Nerdbank.GitVersioning to version 3.9.50 in Csla.Benchmarks.csproj. No other changes were made. * update comments * Refactor benchmark methods to be synchronous Changed FetchAndSerialize and FetchAndCloneInternal from async Task<object?> to synchronous object? methods in PerformanceClonerBenchmark.cs, removing async/await usage. * results
1 parent c282a2f commit f2a1e7a

15 files changed

Lines changed: 18487 additions & 16 deletions

Source/Csla.Benchmarks/Csla.Benchmarks.csproj

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFrameworks>net462;net472;net48;net8.0;net9.0</TargetFrameworks>
5+
<TargetFrameworks>net462;net472;net48;net8.0;net9.0;net10.0</TargetFrameworks>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="BenchmarkDotNet" Version="0.15.2" />
12-
<PackageReference Include="Csla" Version="10.0.0-alpha-0001-g9fc8b77197" />
13-
<PackageReference Include="Csla.Generator.AutoImplementProperties.CSharp" Version="10.0.0-alpha-0001-g9fc8b77197" />
11+
<PackageReference Include="BenchmarkDotNet" Version="0.15.8" />
12+
<PackageReference Include="Csla" Version="10.1.0" />
13+
<PackageReference Include="Csla.Generator.AutoImplementProperties.CSharp" Version="10.1.0" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
1414
</ItemGroup>
15-
1615
</Project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Csla;
2+
3+
namespace PropertyPerf.Client.Model;
4+
5+
public class ChildList : BusinessListBase<ChildList, ChildType1>
6+
{
7+
[FetchChild]
8+
private async Task Fetch([Inject] IChildDataPortal<ChildType1> portal)
9+
{
10+
using (LoadListMode)
11+
{
12+
for (int i = 0; i < 10000; i++)
13+
{
14+
Add(await portal.FetchChildAsync(i));
15+
}
16+
}
17+
}
18+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using Csla;
2+
3+
namespace PropertyPerf.Client.Model;
4+
5+
public class ChildType1 : BusinessBase<ChildType1>
6+
{
7+
public static readonly PropertyInfo<int> IdProperty = RegisterProperty<int>(nameof(Id));
8+
public int Id
9+
{
10+
get => GetProperty(IdProperty);
11+
set => SetProperty(IdProperty, value);
12+
}
13+
14+
[FetchChild]
15+
private async Task Fetch(int id)
16+
{
17+
LoadProperty(IdProperty, id);
18+
}
19+
}
20+
21+
public class ChildType2 : BusinessBase<ChildType2>
22+
{
23+
}
24+
25+
public class ChildType3 : BusinessBase<ChildType3>
26+
{
27+
}
28+
29+
public class ChildType4 : BusinessBase<ChildType4>
30+
{
31+
}
32+
33+
public class ChildType5 : BusinessBase<ChildType5>
34+
{
35+
}
36+
37+
public class ChildType11 : BusinessBase<ChildType11>
38+
{
39+
}
40+
41+
public class ChildType12 : BusinessBase<ChildType12>
42+
{
43+
}
44+
45+
public class ChildType13 : BusinessBase<ChildType13>
46+
{
47+
}
48+
49+
public class ChildType14 : BusinessBase<ChildType14>
50+
{
51+
}
52+
53+
public class ChildType15 : BusinessBase<ChildType15>
54+
{
55+
}

0 commit comments

Comments
 (0)