public async Task<ActionResult> BenchMarkValueInjecter(int nbIteration) { Task<ActionResult> result = Task.Run<ActionResult>(() => { BenchmarkModel resultModel = new BenchmarkModel(); resultModel.Mapper = "ValueInjecte"; //Generate data Customer source = Builder<Customer>.CreateNew().Build(); Stopwatch watcher = Stopwatch.StartNew(); for (int i = 0; i < nbIteration; i++) { CustomerModel model = new CustomerModel(); model.InjectFrom(source); } watcher.Stop(); resultModel.TimeExecuting = watcher.Elapsed.ToString(); return Json(resultModel, JsonRequestBehavior.AllowGet); }); return await result; }
public async Task<ActionResult> BenchMarkDirect(int nbIteration) { Task<ActionResult> result = Task.Run<ActionResult>(() => { BenchmarkModel resultModel = new BenchmarkModel(); resultModel.Mapper = "Direct"; //Generate data Customer source = Builder<Customer>.CreateNew().Build(); Stopwatch watcher = Stopwatch.StartNew(); for (int i = 0; i < nbIteration; i++) { CustomerModel model = new CustomerModel() { Address = source.Address, City = source.City, CompanyName = source.ContactName, ContactName = source.ContactName, ContactTitle = source.ContactTitle, Country = source.Country, Fax = source.Fax, Phone = source.Phone, PostalCode = source.PostalCode, Region = source.Region }; } watcher.Stop(); resultModel.TimeExecuting = watcher.Elapsed.ToString(); return Json(resultModel, JsonRequestBehavior.AllowGet); }); return await result; }