Last active
October 7, 2017 14:08
-
-
Save lbargaoanu/521b0ac2fc45c2ba7444e3f263d19cf8 to your computer and use it in GitHub Desktop.
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
static void Main(string[] args) | |
{ | |
int Count = 20; | |
var sum = 0.0; | |
for(int i=0;i<Count;i++){ | |
var config = new MapperConfiguration(cfg => | |
{ | |
cfg.CreateMap<Entity1, EntityDTO1>().ReverseMap(); | |
cfg.CreateMap<Entity2, EntityDTO2>().ReverseMap(); | |
cfg.CreateMap<Entity3, EntityDTO3>().ReverseMap(); | |
cfg.CreateMap<Entity4, EntityDTO4>().ReverseMap(); | |
cfg.CreateMap<Entity5, EntityDTO5>().ReverseMap(); | |
cfg.CreateMap<Entity6, EntityDTO6>().ReverseMap(); | |
cfg.CreateMap<Entity7, EntityDTO7>().ReverseMap(); | |
cfg.CreateMap<Entity8, EntityDTO8>().ReverseMap(); | |
cfg.CreateMap<Entity9, EntityDTO9>().ReverseMap(); | |
cfg.CreateMap<Entity10, EntityDTO10>().ReverseMap(); | |
cfg.CreateMap<Entity11, EntityDTO11>().ReverseMap(); | |
cfg.CreateMap<Entity12, EntityDTO12>().ReverseMap(); | |
cfg.CreateMap<Entity13, EntityDTO13>().ReverseMap(); | |
cfg.CreateMap<Entity14, EntityDTO14>().ReverseMap(); | |
cfg.CreateMap<Entity15, EntityDTO15>().ReverseMap(); | |
cfg.CreateMap<Entity16, EntityDTO16>().ReverseMap(); | |
cfg.CreateMap<Entity17, EntityDTO17>().ReverseMap(); | |
cfg.CreateMap<Entity18, EntityDTO18>().ReverseMap(); | |
cfg.CreateMap<Entity19, EntityDTO19>().ReverseMap(); | |
cfg.CreateMap<Entity20, EntityDTO20>().ReverseMap(); | |
cfg.CreateMap<Entity21, EntityDTO21>().ReverseMap(); | |
cfg.CreateMap<Entity22, EntityDTO22>().ReverseMap(); | |
cfg.CreateMap<Entity23, EntityDTO23>().ReverseMap(); | |
cfg.CreateMap<Entity24, EntityDTO24>().ReverseMap(); | |
cfg.CreateMap<Entity25, EntityDTO25>().ReverseMap(); | |
cfg.CreateMap<Entity26, EntityDTO26>().ReverseMap(); | |
}); | |
config.AssertConfigurationIsValid(); | |
var mapper = config.CreateMapper(); | |
var list = new List<Entity1>(); | |
var initialize = new Initialize(); | |
list.Add(initialize.GenerateAppointment()); | |
var appointmentsDTO = mapper.Map<EntityDTO1>(list[0]); | |
var timer = Stopwatch.StartNew(); | |
for(int i1=0;i1<100000;i1++){ | |
appointmentsDTO = mapper.Map<EntityDTO1>(list[0]); | |
} | |
// var list2 = new List<Entity1>(); | |
// var entity = new Entity1(); | |
// list2.Add(entity); | |
// var DTOs = mapper.Map<EntityDTO1>(list2[0]); | |
// var list3 = new List<Entity17>(); | |
// var entity17 = new Entity17(); | |
// list3.Add(entity17); | |
// var DTOs17 = mapper.Map<EntityDTO17>(list3[0]); | |
// var list4 = new List<Entity25>(); | |
// var entity25 = new Entity25(); | |
// list4.Add(entity25); | |
// var DTOs25 = mapper.Map<EntityDTO25>(list4[0]); | |
timer.Stop(); | |
Console.WriteLine(timer.Elapsed.TotalMilliseconds); | |
sum+=timer.Elapsed.TotalMilliseconds; | |
GC.Collect(); | |
} | |
Console.WriteLine("Average "+sum/Count); | |
} | |
public class Initialize | |
{ | |
Entity2 appointmentStatusHistory1; | |
Entity8 center1; | |
Entity12 insurance1; | |
Entity14 patient1; | |
Entity17 resource1; | |
Entity20 service1; | |
Entity22 speciality1; | |
public Initialize() | |
{ | |
appointmentStatusHistory1 = new Entity2 { Id = Guid.NewGuid() }; | |
center1 = new Entity8 { Id = Guid.NewGuid() }; | |
insurance1 = new Entity12 { Id = Guid.NewGuid() }; | |
patient1 = new Entity14 { Id = Guid.NewGuid() }; | |
resource1 = new Entity17 { Id = Guid.NewGuid() }; | |
service1 = new Entity20 { Id = Guid.NewGuid() }; | |
speciality1 = new Entity22 { Id = Guid.NewGuid() }; | |
service1.Entity22 = speciality1; | |
service1.Entity22Id = speciality1.Id; | |
} | |
public Entity1 GenerateAppointment() | |
{ | |
var appointment1 = new Entity1 { Id = Guid.NewGuid() }; | |
appointmentStatusHistory1.Entity1 = appointment1; | |
appointmentStatusHistory1.Entity1Id = appointment1.Id; | |
appointment1.Entity8 = center1; | |
appointment1.Entity8Id = center1.Id; | |
appointment1.Entity12 = insurance1; | |
appointment1.Entity12Id = insurance1.Id; | |
appointment1.Entity14 = patient1; | |
appointment1.Entity14Id = patient1.Id; | |
appointment1.Entity17 = resource1; | |
appointment1.Entity17Id = resource1.Id; | |
appointment1.Entity20 = service1; | |
appointment1.Entity20Id = service1.Id; | |
appointment1.Entity22 = speciality1; | |
appointment1.Entity22Id = speciality1.Id; | |
return appointment1; | |
} | |
} | |
public class BaseEntity | |
{ | |
public Guid Id { get; set; } | |
} | |
| |
public class Entity1 : BaseEntity | |
{ | |
public Entity1() | |
{ | |
this.Entities2 = new Entity2(); | |
} | |
public Guid Entity17Id { get; set; } | |
public Entity17 Entity17 { get; set; } | |
public Guid? Entity22Id { get; set; } | |
public Entity22 Entity22 { get; set; } | |
public Guid? Entity20Id { get; set; } | |
public Entity20 Entity20 { get; set; } | |
public Guid? Entity12Id { get; set; } | |
public Entity12 Entity12 { get; set; } | |
public Guid Entity14Id { get; set; } | |
public Entity14 Entity14 { get; set; } | |
public Guid Entity8Id { get; set; } | |
public Entity8 Entity8 { get; set; } | |
public Entity2 Entities2 { get; set; } | |
} | |
| |
public class Entity10 : BaseEntity | |
{ | |
public Entity10() | |
{ | |
this.Entities11 = new Entity11(); | |
} | |
public Entity11 Entities11 { get; set; } | |
} | |
public class Entity11 : BaseEntity | |
{ | |
public Entity11() | |
{ | |
this.Entities10 = new Entity10(); | |
this.Entities8 = new Entity8(); | |
} | |
public Entity10 Entities10 { get; set; } | |
public Entity8 Entities8 { get; set; } | |
} | |
public class Entity12 : BaseEntity | |
{ | |
public Entity12() | |
{ | |
//this.Entities20 = new Entity20(); | |
//this.Entities14 = new Entity14(); | |
//this.Entities16 = new Entity16(); | |
} | |
public Entity20 Entities20 { get; set; } | |
public Entity16 Entities16 { get; set; } | |
public Entity14 Entities14 { get; set; } | |
} | |
public class Entity13 : BaseEntity | |
{ | |
public Guid Entity17Id { get; set; } | |
public Entity17 Entity17 { get; set; } | |
public Guid Entity8Id { get; set; } | |
public Entity8 Entity8 { get; set; } | |
} | |
public class Entity14 : BaseEntity | |
{ | |
public Entity14() | |
{ | |
this.Entities12 = new Entity12(); | |
this.Entities1 = new Entity1(); | |
} | |
public Entity12 Entities12 { get; set; } | |
public Entity1 Entities1 { get; set; } | |
} | |
public class Entity15 : BaseEntity | |
{ | |
public Guid Entity17Id { get; set; } | |
public Entity17 Entity17 { get; set; } | |
} | |
public class Entity16 : BaseEntity | |
{ | |
public Guid Entity20Id { get; set; } | |
public Entity20 Entity20 { get; set; } | |
public Guid Entity12Id { get; set; } | |
public Entity12 Entity12 { get; set; } | |
} | |
| |
public class Entity17 :BaseEntity | |
{ | |
public Entity17() | |
{ | |
//this.Entities20 = new Entity20(); | |
this.Entities8 = new Entity8(); | |
this.Entities5 = new Entity5(); | |
this.Entities18 = new Entity18(); | |
} | |
public Entity20 Entities20 { get; set; } | |
public Entity8 Entities8 { get; set; } | |
public Entity5 Entities5 { get; set; } | |
public Entity18 Entities18 { get; set; } | |
} | |
public class Entity18 : BaseEntity | |
{ | |
public Guid Entity17Id { get; set; } | |
public Entity17 Entity17 { get; set; } | |
public Guid Entity20Id { get; set; } | |
public Entity20 Entity20 { get; set; } | |
} | |
public class Entity19 : BaseEntity | |
{ | |
public Guid Entity25Id { get; set; } | |
public Entity25 Entity25 { get; set; } | |
} | |
public class Entity2 : BaseEntity | |
{ | |
public Guid Entity1Id { get; set; } | |
public Entity1 Entity1 { get; set; } | |
} | |
public class Entity20 : BaseEntity | |
{ | |
public Entity20() | |
{ | |
//this.Entities8 = new Entity8(); | |
//this.Entities26 = new Entity26(); | |
//this.Entities12 = new Entity12(); | |
//this.Entities17 = new Entity17(); | |
//this.Entities21 = new Entity21(); | |
//this.Entities16 = new Entity16(); | |
} | |
public Guid Entity3Id { get; set; } | |
public Entity3 Entity3 { get; set; } | |
public Guid Entity22Id { get; set; } | |
public Entity22 Entity22 { get; set; } | |
public Entity8 Entities8 { get; set; } | |
public Entity26 Entities26 { get; set; } | |
public Entity12 Entities12 { get; set; } | |
public Entity17 Entities17 { get; set; } | |
public Entity21 Entities21 { get; set; } | |
public Entity16 Entities16 { get; set; } | |
} | |
public class Entity21 : BaseEntity | |
{ | |
public Guid Entity20Id { get; set; } | |
public Entity20 Entity20 { get; set; } | |
} | |
public class Entity22 : BaseEntity | |
{ | |
public Entity22() | |
{ | |
this.Entities20 = new Entity20(); | |
this.Entities24 = new Entity24(); | |
} | |
public Entity20 Entities20 { get; set; } | |
public Entity24 Entities24 { get; set; } | |
} | |
| |
public class Entity23 : BaseEntity | |
{ | |
public Guid Entity5Id { get; set; } | |
public Entity5 Entity5 { get; set; } | |
} | |
public class Entity24 : BaseEntity | |
{ | |
public Guid Entity3Id { get; set; } | |
public Entity3 Entity3 { get; set; } | |
public Guid Entity22Id { get; set; } | |
public Entity22 Entity22 { get; set; } | |
} | |
public class Entity25 : BaseEntity | |
{ | |
public Entity25() | |
{ | |
this.Entities19 = new Entity19(); | |
} | |
public Entity19 Entities19 { get; set; } | |
public Guid? Entity8Id { get; set; } | |
public Entity8 Entity8 { get; set; } | |
public Guid? Entity17Id { get; set; } | |
public Entity17 Entity17 { get; set; } | |
} | |
public class Entity26 : BaseEntity | |
{ | |
public Entity26() | |
{ | |
//this.Entities20 = new Entity20(); | |
} | |
public Entity20 Entities20 { get; set; } | |
} | |
public class Entity3 : BaseEntity | |
{ | |
public Entity3() | |
{ | |
this.Entities4 = new Entity4(); | |
this.Entities8 = new Entity8(); | |
} | |
public Entity4 Entities4 { get; set; } | |
public Entity8 Entities8 { get; set; } | |
} | |
public class Entity4 : BaseEntity | |
{ | |
public Guid Entity3Id { get; set; } | |
public Entity3 Entity3 { get; set; } | |
} | |
public class Entity5 : BaseEntity | |
{ | |
public Entity5() | |
{ | |
//this.Entities6 = new Entity6(); | |
//this.TimeSlots = new Entity23(); | |
//this.Entities5 = new Entity5(); | |
} | |
public Guid? Entity8Id { get; set; } | |
public Entity8 Entity8 { get; set; } | |
public Guid? Entity17Id { get; set; } | |
public Entity17 Entity17 { get; set; } | |
public Guid? Entity5Id { get; set; } | |
public Entity5 Entity5Exception { get; set; } | |
public Entity5 Entities5 { get; set; } | |
public Entity6 Entities6 { get; set; } | |
public Entity23 TimeSlots { get; set; } | |
} | |
public class Entity6 : BaseEntity | |
{ | |
public Entity6() | |
{ | |
this.Entities12 = new Entity12(); | |
} | |
public Guid Entity5Id { get; set; } | |
public Entity5 Entity5 { get; set; } | |
public Guid Entity20Id { get; set; } | |
public Entity20 Entity20 { get; set; } | |
public Entity12 Entities12 { get; set; } | |
} | |
public class Entity7 : BaseEntity | |
{ | |
public Guid Entity25Id { get; set; } | |
public Entity25 Entity25 { get; set; } | |
public Guid? Entity14Id { get; set; } | |
public Entity14 Entity14 { get; set; } | |
} | |
public class Entity8 : BaseEntity | |
{ | |
public Entity8() | |
{ | |
//this.Entities20 = new Entity20(); | |
//this.Entities22 = new Entity22(); | |
//this.Entities3 = new Entity3(); | |
//this.Entities11 = new Entity11(); | |
//this.Entities17 = new Entity17(); | |
} | |
public Entity20 Entities20 { get; set; } | |
public Entity17 Entities17 { get; set; } | |
public Entity22 Entities22 { get; set; } | |
public Entity3 Entities3 { get; set; } | |
public Entity11 Entities11 { get; set; } | |
} | |
public class Entity9 : BaseEntity | |
{ | |
public Guid Entity3Id { get; set; } | |
public Entity3 Entity3 { get; set; } | |
} | |
public class EntityDTO1 : BaseEntity | |
{ | |
public EntityDTO1() | |
{ | |
this.Entities2 = new EntityDTO2(); | |
} | |
public Guid Entity17Id { get; set; } | |
public EntityDTO17 Entity17 { get; set; } | |
public Guid? Entity22Id { get; set; } | |
public EntityDTO22 Entity22 { get; set; } | |
public Guid? Entity20Id { get; set; } | |
public EntityDTO20 Entity20 { get; set; } | |
public Guid? Entity12Id { get; set; } | |
public EntityDTO12 Entity12 { get; set; } | |
public Guid Entity14Id { get; set; } | |
public EntityDTO14 Entity14 { get; set; } | |
public Guid Entity8Id { get; set; } | |
public EntityDTO8 Entity8 { get; set; } | |
public EntityDTO2 Entities2 { get; set; } | |
} | |
public class EntityDTO10 : BaseEntity | |
{ | |
public EntityDTO10() | |
{ | |
this.Entities11 = new EntityDTO11(); | |
} | |
public EntityDTO11 Entities11 { get; set; } | |
} | |
public class EntityDTO11 : BaseEntity | |
{ | |
public EntityDTO11() | |
{ | |
//this.Entities10 = new EntityDTO10(); | |
//this.Entities8 = new EntityDTO8(); | |
} | |
public EntityDTO10 Entities10 { get; set; } | |
public EntityDTO8 Entities8 { get; set; } | |
} | |
public class EntityDTO12 : BaseEntity | |
{ | |
public EntityDTO12() | |
{ | |
//this.Entities20 = new EntityDTO20(); | |
//this.Entities14 = new EntityDTO14(); | |
//Entities16 = new EntityDTO16(); | |
} | |
public EntityDTO20 Entities20 { get; set; } | |
public EntityDTO16 Entities16 { get; set; } | |
public EntityDTO14 Entities14 { get; set; } | |
} | |
public class EntityDTO13 : BaseEntity | |
{ | |
public Guid Entity17Id { get; set; } | |
public EntityDTO17 Entity17 { get; set; } | |
public Guid Entity8Id { get; set; } | |
public EntityDTO8 Entity8 { get; set; } | |
} | |
public class EntityDTO14 : BaseEntity | |
{ | |
public EntityDTO14() | |
{ | |
this.Entities12 = new EntityDTO12(); | |
this.Entities1 = new EntityDTO1(); | |
} | |
//public Address Address { get; set; } | |
public EntityDTO12 Entities12 { get; set; } | |
public EntityDTO1 Entities1 { get; set; } | |
} | |
public class EntityDTO15 : BaseEntity | |
{ | |
public EntityDTO15() | |
{ | |
} | |
public Guid Entity17Id { get; set; } | |
public EntityDTO17 Entity17 { get; set; } | |
} | |
public class EntityDTO16 : BaseEntity | |
{ | |
public Guid Entity20Id { get; set; } | |
public EntityDTO20 Entity20 { get; set; } | |
public Guid Entity12Id { get; set; } | |
public EntityDTO12 Entity12 { get; set; } | |
} | |
public class EntityDTO17 :BaseEntity | |
{ | |
public EntityDTO17() | |
{ | |
//this.Entities20 = new EntityDTO20(); | |
//this.Entities8 = new EntityDTO8(); | |
//this.Entities5 = new EntityDTO5(); | |
//this.Entities18 = new EntityDTO18(); | |
} | |
public EntityDTO20 Entities20 { get; set; } | |
public EntityDTO8 Entities8 { get; set; } | |
public EntityDTO5 Entities5 { get; set; } | |
public EntityDTO18 Entities18 { get; set; } | |
} | |
public class EntityDTO18 : BaseEntity | |
{ | |
public Guid Entity17Id { get; set; } | |
public EntityDTO17 Entity17 { get; set; } | |
public Guid Entity20Id { get; set; } | |
public EntityDTO20 Entity20 { get; set; } | |
} | |
public class EntityDTO19 : BaseEntity | |
{ | |
public Guid Entity25Id { get; set; } | |
public EntityDTO25 Entity25 { get; set; } | |
} | |
public class EntityDTO2 : BaseEntity | |
{ | |
public Guid Entity1Id { get; set; } | |
public EntityDTO1 Entity1 { get; set; } | |
} | |
public class EntityDTO20 : BaseEntity | |
{ | |
//TODO Remove comments | |
public EntityDTO20() | |
{ | |
//this.Entities8 = new EntityDTO8(); | |
//this.Entities26 = new EntityDTO26(); | |
//this.Entities12 = new EntityDTO12(); | |
//this.Entities17 = new EntityDTO17(); | |
//this.Entities21 = new EntityDTO21(); | |
//this.Entities16 = new EntityDTO16(); | |
} | |
public Guid Entity3Id { get; set; } | |
public EntityDTO3 Entity3 { get; set; } | |
public Guid Entity22Id { get; set; } | |
public EntityDTO22 Entity22 { get; set; } | |
public EntityDTO8 Entities8 { get; set; } | |
public EntityDTO26 Entities26 { get; set; } | |
public EntityDTO12 Entities12 { get; set; } | |
public EntityDTO17 Entities17 { get; set; } | |
public EntityDTO21 Entities21 { get; set; } | |
public EntityDTO16 Entities16 { get; set; } | |
} | |
public class EntityDTO21 : BaseEntity | |
{ | |
public Guid Entity20Id { get; set; } | |
public EntityDTO20 Entity20 { get; set; } | |
} | |
public class EntityDTO22 : BaseEntity | |
{ | |
public EntityDTO22() | |
{ | |
//this.Entities20 = new EntityDTO20(); | |
//this.Entities24 = new EntityDTO24(); | |
} | |
public EntityDTO20 Entities20 { get; set; } | |
public EntityDTO24 Entities24 { get; set; } | |
} | |
public class EntityDTO23 : BaseEntity | |
{ | |
public Guid Entity5Id { get; set; } | |
public EntityDTO5 Entity5 { get; set; } | |
} | |
public class EntityDTO24 : BaseEntity | |
{ | |
public Guid Entity3Id { get; set; } | |
public EntityDTO3 Entity3 { get; set; } | |
public Guid Entity22Id { get; set; } | |
public EntityDTO22 Entity22 { get; set; } | |
} | |
public class EntityDTO25 : BaseEntity | |
{ | |
public EntityDTO25() | |
{ | |
this.Entities19 = new EntityDTO19(); | |
} | |
public EntityDTO19 Entities19 { get; set; } | |
public Guid? Entity8Id { get; set; } | |
public EntityDTO8 Entity8 { get; set; } | |
public Guid? Entity17Id { get; set; } | |
public EntityDTO17 Entity17 { get; set; } | |
} | |
public class EntityDTO26 : BaseEntity | |
{ | |
public EntityDTO26() | |
{ | |
this.Entities20 = new EntityDTO20(); | |
} | |
public EntityDTO20 Entities20 { get; set; } | |
} | |
public class EntityDTO3 : BaseEntity | |
{ | |
public EntityDTO3() | |
{ | |
//this.Entities4 = new EntityDTO4(); | |
//this.Entities8 = new EntityDTO8(); | |
} | |
public EntityDTO4 Entities4 { get; set; } | |
public EntityDTO8 Entities8 { get; set; } | |
} | |
public class EntityDTO4 : BaseEntity | |
{ | |
public Guid Entity3Id { get; set; } | |
public EntityDTO3 Entity3 { get; set; } | |
} | |
public class EntityDTO5 : BaseEntity | |
{ | |
public EntityDTO5() | |
{ | |
//this.Entities6 = new EntityDTO6(); | |
//this.TimeSlots = new EntityDTO23(); | |
//this.Entities5 = new EntityDTO5(); | |
} | |
public Guid? Entity8Id { get; set; } | |
public EntityDTO8 Entity8 { get; set; } | |
public Guid? Entity17Id { get; set; } | |
public EntityDTO17 Entity17 { get; set; } | |
public Guid? Entity5Id { get; set; } | |
public EntityDTO5 Entity5Exception { get; set; } | |
public EntityDTO5 Entities5 { get; set; } | |
public EntityDTO6 Entities6 { get; set; } | |
public EntityDTO23 TimeSlots { get; set; } | |
} | |
public class EntityDTO6 : BaseEntity | |
{ | |
public EntityDTO6() | |
{ | |
//this.Entities12 = new EntityDTO12(); | |
} | |
public Guid Entity5Id { get; set; } | |
public EntityDTO5 Entity5 { get; set; } | |
public Guid Entity20Id { get; set; } | |
public EntityDTO20 Entity20 { get; set; } | |
public EntityDTO12 Entities12 { get; set; } | |
} | |
public class EntityDTO7 : BaseEntity | |
{ | |
public Guid Entity25Id { get; set; } | |
public EntityDTO25 Entity25 { get; set; } | |
public Guid? Entity14Id { get; set; } | |
public EntityDTO14 Entity14 { get; set; } | |
} | |
public class EntityDTO8 : BaseEntity | |
{ | |
public EntityDTO8() | |
{ | |
this.Entities20 = new EntityDTO20(); | |
this.Entities22 = new EntityDTO22(); | |
this.Entities3 = new EntityDTO3(); | |
this.Entities11 = new EntityDTO11(); | |
this.Entities17 = new EntityDTO17(); | |
} | |
public EntityDTO20 Entities20 { get; set; } | |
public EntityDTO17 Entities17 { get; set; } | |
public EntityDTO22 Entities22 { get; set; } | |
public EntityDTO3 Entities3 { get; set; } | |
public EntityDTO11 Entities11 { get; set; } | |
} | |
public class EntityDTO9 : BaseEntity | |
{ | |
public Guid Entity3Id { get; set; } | |
public EntityDTO3 Entity3 { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment