File tree Expand file tree Collapse file tree 1 file changed +29
-8
lines changed
samples/ValidationRulesTest/ValidationRulesTest/Models Expand file tree Collapse file tree 1 file changed +29
-8
lines changed Original file line number Diff line number Diff line change @@ -40,14 +40,35 @@ public bool Validate()
4040
4141 public User Map ( )
4242 {
43- //return new User
44- //{
45- // Name = this.Name.Value,
46- // LastName = this.LastName.Value,
47- // Email = this.Email.Value
48- //};
49-
50- return this . MapValidator < User , UserValidator > ( ) ;
43+ var stopper = new System . Diagnostics . Stopwatch ( ) ;
44+ var testRuns = 1000 ; // 1 second
45+
46+ stopper . Start ( ) ;
47+
48+ // Simple Manual Mapper
49+ var manualMapperUser = new User
50+ {
51+ Name = this . Name . Value ,
52+ LastName = this . LastName . Value ,
53+ Email = this . Email . Value
54+ } ;
55+
56+ stopper . Stop ( ) ;
57+
58+ var time1 = stopper . Elapsed . TotalMilliseconds / ( double ) testRuns ;
59+ System . Console . WriteLine ( "ManualMapper: " + time1 ) ; // Elapsed time: 0.002
60+
61+ stopper . Restart ( ) ;
62+
63+ // Extension Mapper with simple Model
64+ var extMapperUser = this . MapValidator < User , UserValidator > ( ) ;
65+
66+ stopper . Stop ( ) ;
67+
68+ var time2 = stopper . Elapsed . TotalMilliseconds / ( double ) testRuns ;
69+ System . Console . WriteLine ( "ExtensionMapper: " + time2 ) ; // Elapsed time: 0.013
70+
71+ return manualMapperUser ;
5172 }
5273 }
5374}
You can’t perform that action at this time.
0 commit comments