1
+ using BenchmarkDotNet . Attributes ;
2
+ using Force . DeepCloner ;
3
+
4
+ namespace FastCloner . Benchmark ;
5
+
6
+ [ RankColumn ]
7
+ [ Orderer ( BenchmarkDotNet . Order . SummaryOrderPolicy . FastestToSlowest ) ]
8
+ [ MemoryDiagnoser ]
9
+ public class Minimal
10
+ {
11
+ private TestObject testData ;
12
+
13
+ [ GlobalSetup ]
14
+ public void Setup ( )
15
+ {
16
+ testData = new TestObject
17
+ {
18
+ Id = 1 ,
19
+ Name = "Test" ,
20
+ NestedObject = new NestedObject
21
+ {
22
+ Value = 42 ,
23
+ Description = "Nested test"
24
+ }
25
+ } ;
26
+ }
27
+
28
+ [ Benchmark ( Baseline = true ) ]
29
+ public object ? FastCloner ( )
30
+ {
31
+ return global ::FastCloner . FastCloner . DeepClone ( testData ) ;
32
+ }
33
+
34
+ [ Benchmark ]
35
+ public object ? DeepCopier ( )
36
+ {
37
+ return global ::DeepCopier . Copier . Copy ( testData ) ;
38
+ }
39
+
40
+ [ Benchmark ]
41
+ public object ? DeepCopy ( )
42
+ {
43
+ return global ::DeepCopy . DeepCopier . Copy ( testData ) ;
44
+ }
45
+
46
+ [ Benchmark ]
47
+ public object DeepCopyExpression ( )
48
+ {
49
+ return global ::DeepCopy . ObjectCloner . Clone ( testData ) ;
50
+ }
51
+
52
+ [ Benchmark ]
53
+ public object ? FastDeepCloner ( )
54
+ {
55
+ return global ::FastDeepCloner . DeepCloner . Clone ( testData ) ;
56
+ }
57
+
58
+ [ Benchmark ]
59
+ public object ? DeepCloner ( )
60
+ {
61
+ return testData . DeepClone ( ) ;
62
+ }
63
+
64
+ public class TestObject
65
+ {
66
+ public int Id { get ; set ; }
67
+ public string Name { get ; set ; }
68
+ public NestedObject NestedObject { get ; set ; }
69
+ }
70
+
71
+ public class NestedObject
72
+ {
73
+ public int Value { get ; set ; }
74
+ public string Description { get ; set ; }
75
+ }
76
+ }
0 commit comments