public async Task <Schools> GetJson() { Schools schoolList = await _support.GetJson(_clientFactory); ErrorString = _support.ErrorString; return(schoolList); }
public async Task <Performance> Get() { Stopwatch stopWatch; Performance perf = new Performance { InitPerformance = 0, DapperPerformance = 0, EFPerformance = 0, JsonPerformance = 0, SimPerformance = 0, DapperPerformance2 = 0, EFPerformance2 = 0, JsonPerformance2 = 0, SimPerformance2 = 0, DapperUpdatePerformance = 0, EFUpdatePerformance = 0, SimUpdatePerformance = 0, Records = 0, MaxPage = MaxPage }; if (UseSim == true) { perf.UseSIM = 1; } else { perf.UseSIM = 0; } if (UseEF == true) { perf.UseEF = 1; } else { perf.UseEF = 0; } if (UseDapper == true) { perf.UseDapper = 1; } else { perf.UseDapper = 0; } if (AllowEF == true) { perf.AllowEF = 1; } else { perf.AllowEF = 0; } if (AllowDapper == true) { perf.AllowDapper = 1; } else { perf.AllowDapper = 0; } try { _logger.LogInformation("Initialize"); stopWatch = Stopwatch.StartNew(); await Initialize(); stopWatch.Stop(); perf.InitPerformance = (int)stopWatch.ElapsedMilliseconds; _logger.LogInformation("Initialzie Performance is {perf}", perf.InitPerformance); perf.Records = Records; perf.DapperUpdatePerformance = DapperUpdatePerformance; perf.EFUpdatePerformance = EFUpdatePerformance; perf.SimUpdatePerformance = SimUpdatePerformance; _logger.LogInformation("Loading Json"); stopWatch = Stopwatch.StartNew(); Schools schoolList = await _support.GetJson(_clientFactory); stopWatch.Stop(); perf.JsonPerformance = (int)stopWatch.ElapsedMilliseconds; _logger.LogInformation("Json Performance is {perf}", perf.JsonPerformance); if (AllowDapper == true) { _logger.LogInformation("Loading Dapper Sql Database"); stopWatch = Stopwatch.StartNew(); schoolList = await _support.GetData(_sqlService, 0, 0); stopWatch.Stop(); perf.DapperPerformance = (int)stopWatch.ElapsedMilliseconds; _logger.LogInformation("Dapper Performance is {perf}", perf.DapperPerformance); } if (AllowEF == true) { _logger.LogInformation("Loading Entity Framework Sql Database"); stopWatch = Stopwatch.StartNew(); schoolList = await _support.GetData(_efService, 0, 0); stopWatch.Stop(); perf.EFPerformance = (int)stopWatch.ElapsedMilliseconds; _logger.LogInformation("Entity Framework Performance is {perf}", perf.EFPerformance); } if (UseSim == true) { _logger.LogInformation("Loading Simulated Database"); stopWatch = Stopwatch.StartNew(); schoolList = await _support.GetData(_simService, 0, 0); stopWatch.Stop(); perf.SimPerformance = (int)stopWatch.ElapsedMilliseconds; _logger.LogInformation("Simulated Performance is {perf}", perf.SimPerformance); } _logger.LogInformation("Loading Json"); stopWatch = Stopwatch.StartNew(); schoolList = await _support.GetJson(_clientFactory); stopWatch.Stop(); perf.JsonPerformance2 = (int)stopWatch.ElapsedMilliseconds; _logger.LogInformation("Json Performance (2) is {perf}", perf.JsonPerformance2); if (AllowDapper == true) { _logger.LogInformation("Loading Dapper Sql Database"); stopWatch = Stopwatch.StartNew(); schoolList = await _support.GetData(_sqlService, 0, 0); stopWatch.Stop(); perf.DapperPerformance2 = (int)stopWatch.ElapsedMilliseconds; _logger.LogInformation("Dapper Performance (2) is {perf}", perf.DapperPerformance2); } if (AllowEF == true) { _logger.LogInformation("Loading Entity Framework Sql Database"); stopWatch = Stopwatch.StartNew(); schoolList = await _support.GetData(_efService, 0, 0); stopWatch.Stop(); perf.EFPerformance2 = (int)stopWatch.ElapsedMilliseconds; _logger.LogInformation("Entity Framework Performance (2) is {perf}", perf.EFPerformance2); } if (UseSim == true) { _logger.LogInformation("Loading Simulated Database"); stopWatch = Stopwatch.StartNew(); schoolList = await _support.GetData(_simService, 0, 0); stopWatch.Stop(); perf.SimPerformance2 = (int)stopWatch.ElapsedMilliseconds; _logger.LogInformation("Simulated Performance (2) is {perf}", perf.SimPerformance); } } catch (Exception e) { _logger.LogError("Exception doing performance test", e); } return(perf); }