private AppStats CalculateAppStats() { var appStats = new AppStats { Id = Guid.NewGuid(), MethodStats = new List <MethodExecutionStats>(), EndDate = DateTime.Now, StartDate = _infoReserve.Created, ClientIp = LocalIp, ClientMachine = Environment.MachineName, ApplicationName = ConfigurationManager.AppSettings["HeartbeatApplicationName"] }; var methods = _infoReserve.ExecStats .Select(m => m.MethodName) .Distinct(); foreach (var method in methods) { var methodStats = new MethodExecutionStats { MethodName = method, ExecutionCount = _infoReserve.ExecStats.Count(m => m.MethodName == method), ExceptionCount = _infoReserve.ExecStats.Where(m => m.HasException).Count(m => m.MethodName == method), AverageDuration = (int)_infoReserve.ExecStats.Where(m => m.MethodName == method).Average(m => m.Duration), MaxDuration = _infoReserve.ExecStats.Where(m => m.MethodName == method).Max(m => m.Duration), MinDuration = _infoReserve.ExecStats.Where(m => m.MethodName == method).Min(m => m.Duration) }; appStats.MethodStats.Add(methodStats); } return(appStats); }
private AppStats CalculateAppStats() { var appStats = new AppStats { Id = Guid.NewGuid(), MethodStats = new List<MethodExecutionStats>(), EndDate = DateTime.Now, StartDate = _infoReserve.Created, ClientIp = LocalIp, ClientMachine = Environment.MachineName, ApplicationName = ConfigurationManager.AppSettings["HeartbeatApplicationName"] }; var methods = _infoReserve.ExecStats .Select(m => m.MethodName) .Distinct(); foreach (var method in methods) { var methodStats = new MethodExecutionStats { MethodName = method, ExecutionCount = _infoReserve.ExecStats.Count(m => m.MethodName == method), ExceptionCount = _infoReserve.ExecStats.Where(m=> m.HasException).Count(m => m.MethodName == method), AverageDuration = (int) _infoReserve.ExecStats.Where(m => m.MethodName == method).Average(m => m.Duration), MaxDuration = _infoReserve.ExecStats.Where(m => m.MethodName == method).Max(m => m.Duration), MinDuration = _infoReserve.ExecStats.Where(m => m.MethodName == method).Min(m => m.Duration) }; appStats.MethodStats.Add(methodStats); } return appStats; }