public static List<LoadTestingStatisticItemModel> GetByType(List<LoadTestingStatisticsModel> stats) { var res = new List<LoadTestingStatisticItemModel>(); foreach(var stat in stats) { foreach(var item in stat.Items) { var r = res.FirstOrDefault(c => c.Type == item.Type); if(r == null) { r = new LoadTestingStatisticItemModel() { Type = item.Type, MinDuration = item.MinDuration, MaxDuration = item.MaxDuration }; res.Add(r); } else { if(item.MinDuration < r.MinDuration) r.MinDuration = item.MinDuration; if(item.MaxDuration > r.MaxDuration) r.MaxDuration = item.MaxDuration; } r.Duration += item.Duration; r.Count += item.Count; } } return res; }
public static List <LoadTestingStatisticItemModel> GetByType(List <LoadTestingStatisticsModel> stats) { var res = new List <LoadTestingStatisticItemModel>(); foreach (var stat in stats) { foreach (var item in stat.Items) { var r = res.FirstOrDefault(c => c.Type == item.Type); if (r == null) { r = new LoadTestingStatisticItemModel() { Type = item.Type, MinDuration = item.MinDuration, MaxDuration = item.MaxDuration }; res.Add(r); } else { if (item.MinDuration < r.MinDuration) { r.MinDuration = item.MinDuration; } if (item.MaxDuration > r.MaxDuration) { r.MaxDuration = item.MaxDuration; } } r.Duration += item.Duration; r.Count += item.Count; } } return(res); }
private List<LoadTestingStatisticsModel> GetStatistics(int unit) { TimeSpan ts = new TimeSpan(0, 0, unit); var res = new List<LoadTestingStatisticsModel>(); var dbcoll = WorkflowInit.Provider.Store.GetCollection<LoadTestingOperationModel>("LoadTestingOperationModel"); foreach (var op in dbcoll.FindAll()) { op.Date = Floor(op.Date, ts); var r = res.FirstOrDefault(c => c.Date == op.Date); if (r == null) { r = new LoadTestingStatisticsModel() { Date = op.Date }; res.Add(r); } var item = r.Items.FirstOrDefault(c => c.Type == op.Type); if (item == null) { item = new LoadTestingStatisticItemModel() { Type = op.Type }; r.Items.Add(item); } item.Duration += op.DurationMilliseconds; item.CheckDurationMinMax(op.DurationMilliseconds); item.Count++; } return res; }
private List<LoadTestingStatisticsModel> GetStatistics(int unit) { TimeSpan ts = new TimeSpan(0, 0, unit); var res = new List<LoadTestingStatisticsModel>(); using (var context = new DataModelDataContext()) { foreach (var op in context.LoadTestingOperations) { op.Date = Floor(op.Date, ts); var r = res.FirstOrDefault(c => c.Date == op.Date); if (r == null) { r = new LoadTestingStatisticsModel() { Date = op.Date }; res.Add(r); } var item = r.Items.FirstOrDefault(c => c.Type == op.Type); if (item == null) { item = new LoadTestingStatisticItemModel() { Type = op.Type }; r.Items.Add(item); } item.Duration += op.DurationMilliseconds; item.CheckDurationMinMax(op.DurationMilliseconds); item.Count++; } } return res; }
private List<LoadTestingStatisticsModel> GetStatistics(int unit) { const int pageSize = 128; TimeSpan ts = new TimeSpan(0, 0, unit); var res = new List<LoadTestingStatisticsModel>(); var session = WF.Sample.Business.Workflow.WorkflowInit.Provider.Store.OpenSession(); long count = session.Query<LoadTestingOperationModel>().LongCount(); int actual = 0; do { if(session.Advanced.NumberOfRequests >= session.Advanced.MaxNumberOfRequestsPerSession) { session.Dispose(); session = WF.Sample.Business.Workflow.WorkflowInit.Provider.Store.OpenSession(); } var ops = session.Advanced .LuceneQuery<LoadTestingOperationModel>() .Skip(actual) .Take(pageSize); actual = actual + pageSize; foreach (var op in ops) { op.Date = Floor(op.Date, ts); var r = res.FirstOrDefault(c => c.Date == op.Date); if (r == null) { r = new LoadTestingStatisticsModel() { Date = op.Date }; res.Add(r); } var item = r.Items.FirstOrDefault(c => c.Type == op.Type); if (item == null) { item = new LoadTestingStatisticItemModel() { Type = op.Type }; r.Items.Add(item); } item.Duration += op.DurationMilliseconds; item.CheckDurationMinMax(op.DurationMilliseconds); item.Count++; } if (actual >= count) break; } while (true); session.Dispose(); return res; }