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; }