public LoadTestResultList(Entity.LoadTestRun entityLoadTestRun) { LoadTestName = entityLoadTestRun.LoadTestName; LoadTestRunId = entityLoadTestRun.LoadTestRunId; RunId = entityLoadTestRun.RunId; Description = entityLoadTestRun.Description; StartTime = entityLoadTestRun.StartTime.Value.AddHours(Constants.Malaysia_Time_Zone); EndTime = entityLoadTestRun.EndTime.Value.AddHours(Constants.Malaysia_Time_Zone); RunDuration = entityLoadTestRun.RunDuration; WarmupTime = entityLoadTestRun.WarmupTime; RunSettingUsed = entityLoadTestRun.RunSettingUsed; IsLocalRun = entityLoadTestRun.IsLocalRun; Outcome = entityLoadTestRun.Outcome; }
public LoadTestResultModels(Entity.LoadTestRun entityLoadTestRun, Entity.db_LoadTest2010Entities db, bool compare = false) { RunId = entityLoadTestRun.RunId; LoadTestRunId = entityLoadTestRun.LoadTestRunId; LoadTestName = entityLoadTestRun.LoadTestName; Description = entityLoadTestRun.Description; StartTime = entityLoadTestRun.StartTime.Value.AddHours(Constants.Malaysia_Time_Zone); EndTime = entityLoadTestRun.EndTime.Value.AddHours(Constants.Malaysia_Time_Zone); RunDuration = entityLoadTestRun.RunDuration; WarmupTime = entityLoadTestRun.WarmupTime; RunSettingUsed = entityLoadTestRun.RunSettingUsed; IsLocalRun = entityLoadTestRun.IsLocalRun; Outcome = entityLoadTestRun.Outcome; NumberOfAgents = entityLoadTestRun.LoadTestRunAgents.Select(e => e.AgentId).Distinct().Count(); SlowestTestName = db.LoadTestCases.FirstOrDefault(x => x.LoadTestRunId == entityLoadTestRun.LoadTestRunId).TestCaseName; SlowestTestTime = db.LoadTestTestSummaryDatas.Where(x => x.LoadTestRunId == entityLoadTestRun.LoadTestRunId).OrderByDescending(e => e.Percentile95).Take(5).Sum(p => p.Percentile95); MaxUserLoad = db.LoadTestTestDetails.Where(x => x.LoadTestRunId == entityLoadTestRun.LoadTestRunId).Select(e => e.UserId).Distinct().Count(); var entityLoadTestTestSummaryDatas = db.LoadTestTestSummaryDatas.Where(x => x.LoadTestRunId == entityLoadTestRun.LoadTestRunId).ToList(); if (entityLoadTestTestSummaryDatas.Count > 0) { TestsPerSec = (float)entityLoadTestTestSummaryDatas.Sum(x => x.TestsRun) / entityLoadTestRun.RunDuration; } TestsFailed = entityLoadTestRun.LoadTestTestLogs.Count(); AvgTestTime = db.LoadTestTestSummaryDatas.Where(x => x.LoadTestRunId == entityLoadTestRun.LoadTestRunId).Sum(x => x.Average); PagesPerSec = (double)entityLoadTestRun.LoadTestPageSummaryDatas.Sum(x => x.PageCount) / entityLoadTestRun.RunDuration; AvgPageTime = (double)entityLoadTestRun.LoadTestPageSummaryDatas.Sum(x => x.Average) / entityLoadTestRun.LoadTestPageSummaryDatas.Count(); var entityLoadTestTransactionSummaryData = db.LoadTestTransactionSummaryDatas.FirstOrDefault(x => x.LoadTestRunId == entityLoadTestRun.LoadTestRunId); if (entityLoadTestTransactionSummaryData != null) { TransactionsPerSec = (double)entityLoadTestTransactionSummaryData.TransactionCount / entityLoadTestRun.RunDuration; AvgTransactionTime = entityLoadTestTransactionSummaryData.Average; } RequestsFailed = entityLoadTestRun.LoadTestMessages.Select(x => x.RequestId).Distinct().Count(); AvgResponseTime = db.LoadTestPageDetails.Where(x => x.LoadTestRunId == entityLoadTestRun.LoadTestRunId).Average(x => x.ResponseTime); //TotalTests = db.LoadTestTestSummaryDatas.Where(x => x.LoadTestRunId == entityLoadTestRun.LoadTestRunId).Sum(x => x.TestsRun); if (compare) { LoadTestErrors = new List <LoadTestErrors>(); if (entityLoadTestRun.LoadTestMessages != null) { foreach (var LoadTestError in entityLoadTestRun.LoadTestMessages.GroupBy(p => p.SubType).Select(g => new { SubType = g.Key, Count = g.Count(), MessageText = g.FirstOrDefault().MessageText, ErrorType = g.FirstOrDefault().MessageType, LoadTestRunId = g.FirstOrDefault().LoadTestRunId })) { LoadTestErrors.Add(new LoadTestErrors { ErrorSubtype = LoadTestError.SubType, ErrorCount = LoadTestError.Count, ErrorLastMessage = LoadTestError.MessageText, ErrorType = LoadTestError.ErrorType, LoadTestRunId = LoadTestError.LoadTestRunId, }); } } PageResults = new List <PageResultsModels>(); if (entityLoadTestRun.LoadTestPageSummaryDatas != null) { foreach (var LoadTestPageSummaryData in entityLoadTestRun.LoadTestPageSummaryDatas.OrderByDescending(x => x.Average)) { PageResults.Add(new PageResultsModels(LoadTestPageSummaryData, db)); } } SlowestPages = new List <SlowestPagesModel>(); if (entityLoadTestRun.LoadTestPageSummaryDatas != null) { foreach (var LoadTestPageSummaryData in entityLoadTestRun.LoadTestPageSummaryDatas.OrderByDescending(x => x.Percentile95).Take(5)) { SlowestPages.Add(new SlowestPagesModel(LoadTestPageSummaryData, db)); } } TestResults = new List <TestResultsModels>(); if (entityLoadTestTestSummaryDatas != null) { foreach (var entityLoadTestTestSummaryData in entityLoadTestTestSummaryDatas) { TestResults.Add(new TestResultsModels(entityLoadTestTestSummaryData, db)); } } } }