private static void PrintDebugStats(StatisticsReport report) { var dataToMessage = JsonConvert.SerializeObject(report.StatisticsPerPeriod.Where(x => x.MessagesQuantity > 0), Formatting.Indented); var builder = new StringBuilder(dataToMessage).FormatMessageIntoBlock("json"); Log.Information(builder.ToString()); }
public string GetImageStatisticsPerPeriod(StatisticsReport report) { var dates = report.StatisticsPerPeriod.Select(x => x.TimeRange.Start); var period = report.StatisticsPerPeriod.First().Period; var labels = period switch { Period.Hour => dates.Select(x => x.ToString("yyyy-MM-dd HH")), Period.Day => dates.Select(x => x.ToString("yyyy-MM-dd")), Period.Week => dates.Select(x => x.ToString("yyyy-MM-dd")), Period.Month => dates.Select(x => x.ToString("yyyy-MM")), _ => new List <string>() }; var chart = new Chart { Type = "line", Labels = labels.Select(x => x.ToString()).Reverse(), Data = new Dataset { Label = "Messages", Data = report.StatisticsPerPeriod.Select(x => x.MessagesQuantity).Reverse() } }; var imagePath = this._quickchartService.GetImage(chart); return(imagePath); } }
/// <summary> /// Initializes a new instance of the <see cref="RoutedProcessingContext" /> class. /// </summary> /// <param name="infoAction">The info action.</param> /// <param name="warningAction">The warning action.</param> /// <param name="errorAction"></param> /// <param name="progressAction"></param> public RoutedProcessingContext(Action <string> infoAction, Action <string> warningAction, Action <string> errorAction, Action <string> progressAction) { WriteInfoAction = infoAction; WriteWarningAction = warningAction; WriteErrorAction = errorAction; WriteProgressAction = progressAction; Report = new StatisticsReport(WriteError, WriteWarning, WriteInfo); }
public void Handle(CoreProjectionStatusMessage.StatisticsReport message) { var command = new StatisticsReport { Id = message.ProjectionId.ToString("N"), Statistics = message.Statistics }; _writer.PublishCommand("$statistics-report", command); }
/// <summary> /// Initializes a new instance of the <see cref="FrontEndProcessingContext" /> class. /// </summary> /// <param name="logCallback">The log callback.</param> public FrontEndProcessingContext(Action <string> logCallback) { if (logCallback == null) { throw new ArgumentNullException(nameof(logCallback)); } _logCallback = logCallback; Report = new StatisticsReport( ); }
protected void Mock( IEnumerable <Dictionary <string, object> > packageDownloadsReport = null, IEnumerable <Dictionary <string, object> > packageVersionDownloadsReport = null, IEnumerable <Dictionary <string, object> > communityPackageDownloadsReport = null, IEnumerable <Dictionary <string, object> > communityPackageVersionDownloadsReport = null, DateTime?packagesLastUpdateTimeUtc = null, DateTime?packageVersionsLastUpdateTimeUtc = null, DateTime?communityPackagesLastUpdateTimeUtc = null, DateTime?communityPackageVersionsLastUpdateTimeUtc = null) { packageDownloadsReport = packageDownloadsReport ?? PackageDownloadsReport; packageVersionDownloadsReport = packageVersionDownloadsReport ?? PackageVersionDownloadsReport; communityPackageDownloadsReport = communityPackageDownloadsReport ?? PackageDownloadsReport; communityPackageVersionDownloadsReport = communityPackageVersionDownloadsReport ?? PackageVersionDownloadsReport; // Set the default last updated timestamps only if all timestamps are null. if (!packagesLastUpdateTimeUtc.HasValue && !packageVersionsLastUpdateTimeUtc.HasValue && !communityPackagesLastUpdateTimeUtc.HasValue && !communityPackageVersionsLastUpdateTimeUtc.HasValue) { packagesLastUpdateTimeUtc = packagesLastUpdateTimeUtc ?? LastUpdatedUtcDefault; packageVersionsLastUpdateTimeUtc = packageVersionsLastUpdateTimeUtc ?? LastUpdatedUtcDefault; communityPackagesLastUpdateTimeUtc = communityPackagesLastUpdateTimeUtc ?? LastUpdatedUtcDefault; communityPackageVersionsLastUpdateTimeUtc = communityPackageVersionsLastUpdateTimeUtc ?? LastUpdatedUtcDefault; } Task <StatisticsReport> CreateReport(IEnumerable <Dictionary <string, object> > report, DateTime?lastUpdatedUtc) { var content = JsonConvert.SerializeObject(report); var result = new StatisticsReport(content, lastUpdatedUtc); return(Task.FromResult(result)); } _reportService .Setup(s => s.Load(It.Is <string>(n => n == "recentpopularity.json"))) .Returns(CreateReport(packageDownloadsReport, packagesLastUpdateTimeUtc)); _reportService .Setup(s => s.Load(It.Is <string>(n => n == "recentcommunitypopularity.json"))) .Returns(CreateReport(communityPackageDownloadsReport, communityPackagesLastUpdateTimeUtc)); _reportService .Setup(s => s.Load(It.Is <string>(n => n == "recentpopularitydetail.json"))) .Returns(CreateReport(packageVersionDownloadsReport, packageVersionsLastUpdateTimeUtc)); _reportService .Setup(s => s.Load(It.Is <string>(n => n == "recentcommunitypopularitydetail.json"))) .Returns(CreateReport(communityPackageVersionDownloadsReport, communityPackageVersionsLastUpdateTimeUtc)); }
public static BmpMessage Create(byte[] data) { var commonHeaderLength = 6; var perPeerHeaderLength = 42; var msgHeader = new BmpHeader(data); BmpMessage msg; switch (msgHeader.MessageType) { case BmpMessageType.Initiation: msg = new BmpInitiation(); break; case BmpMessageType.RouteMonitoring: msg = new RouteMonitoring(); break; case BmpMessageType.StatisticsReport: msg = new StatisticsReport(); break; case BmpMessageType.PeerDown: msg = new PeerDownNotification(); break; case BmpMessageType.PeerUp: msg = new PeerUpNotification(); break; case BmpMessageType.Termination: msg = new BmpTermination(); break; default: return(null); } msg.BmpHeader = msgHeader; var offset = commonHeaderLength; if (msgHeader.MessageType != BmpMessageType.Initiation) { msg.PeerHeader = new PerPeerHeader(data, offset); offset += perPeerHeaderLength; } msg.Decode(data, offset); return(msg); }
public HttpResponseMessage StageApplication(Guid id) { try { StatisticsReport report = AppManagerServiceImpl.StageApplication(id); var data = new AppStagingData(report); return(new HttpResponseMessage <AppStagingData>(data, HttpStatusCode.OK)); } catch (Exception e) { throw new Exception($"Failed to stage application {id}", e); } }
/// <summary>Collects tool average open time from a report.</summary> protected override void ProcessToolUsageData(StatisticsReport report, ToolUsageData tool) { // Skip if there's no information about open time if (!tool.UIStats.ContainsKey("OpenTime.Avg")) { return; } // Else get the info float avgTimeFromReport = float.Parse(tool.UIStats["OpenTime.Avg"]); // If there was no information about open time of this tool before, add a container for it. if (!statsAverageData.ContainsKey(tool.ToolName)) { statsAverageData.Add(tool.ToolName, new StatAverageInfo()); } StatAverageInfo averageInfo = statsAverageData[tool.ToolName]; // Add info averageInfo.StatSum += avgTimeFromReport; averageInfo.ReportsCount++; }
// GET: Statistics public ActionResult Index(string measurement, string organization, DateTime?FromDate, DateTime?ToDate) { if (User.Identity.IsAuthenticated) { if (IsAdmin()) { ViewBag.Role = "Admin"; } } StatisticsReport model = null; try { if (string.IsNullOrEmpty(measurement)) { measurement = Measurement.NumberOfMetadataTotal; } if (!FromDate.HasValue) { FromDate = DateTime.Now.AddYears(-1); } if (!ToDate.HasValue) { ToDate = DateTime.Now; } model = _statisticsService.GetReport(measurement, organization, FromDate, ToDate); } catch (Exception ex) { Log.Error(ex); return(View("Error")); } return(View(model)); }
/// <summary> /// Gets the count. /// </summary> /// <param name="report">The report.</param> /// <param name="countId">The count identifier.</param> /// <returns></returns> private int GetCount(StatisticsReport report, string countId) { string lookup = null; switch (countId) { case "SourceEntityCount": lookup = "Current Application Entities"; break; case "TargetEntityCount": lookup = "Copied Entities"; break; case "SourceRelationshipCount": lookup = "Current Application Relationships"; break; case "TargetRelationshipCount": lookup = "Copied Relationships"; break; case "SourceEntityDataCount_NVarChar": lookup = "Copied NVarChar Data"; break; } StatisticsCount count = report.Counts.FirstOrDefault(pair => pair.Name == lookup); if (count != null) { return(count.Count); } return(-1); }
/// <summary> /// Initializes a new instance of the <see cref="AppStagingData" /> class. /// </summary> public AppStagingData(StatisticsReport report) { if (report == null) { throw new ArgumentNullException("report"); } var entities = new List <EntityEntry>( ); if (report.AddedEntities != null && report.AddedEntities.Any( )) { entities.AddRange(report.AddedEntities); } if (report.RemovedEntities != null && report.RemovedEntities.Any( )) { entities.AddRange(report.RemovedEntities); } if (report.UpdatedEntities != null && report.UpdatedEntities.Any( )) { entities.AddRange(report.UpdatedEntities); } if (report.UnchangedEntities != null && report.UnchangedEntities.Any( )) { entities.AddRange(report.UnchangedEntities); } Entities = entities; if (report.CardinalityViolations != null && report.CardinalityViolations.Any( )) { CardinalityViolations = LoadViolationData(report.CardinalityViolations); } }
public void Bug24784( ) { Guid newInstanceId = Guid.NewGuid( ); var application = TestMigrationHelper.CreateAppLibraryApplication( ); application.CreateAppEntityRow(application.AppVerUid, newInstanceId); application.CreateAppDataRow(TableNames.AppDataNVarChar, application.AppVerUid, newInstanceId, AppDetails.NameUid, "Violation Test"); application.SetCardinality(CardinalityEnum_Enumeration.OneToOne); application.CreateAppRelationshipRow(application.AppVerUid, AppDetails.IsOfTypeUid, newInstanceId, application.FromTypeUid); application.CreateAppRelationshipRow(application.AppVerUid, AppDetails.InSolutionUid, newInstanceId, application.SolutionUid); application.CreateAppRelationshipRow(application.AppVerUid, AppDetails.SecurityOwnerUid, newInstanceId, AppDetails.AdministratorUserAccountUid); application.CreateAppRelationshipRow(application.AppVerUid, application.RelationshipUid, newInstanceId, application.ToInstanceUid); TestMigrationHelper.SaveAppLibraryApplication(application); AppManager.DeployApp(RunAsDefaultTenant.DefaultTenantName, application.SolutionUid.ToString("B")); StatisticsReport statisticsReport = AppManager.StageApp(RunAsDefaultTenant.DefaultTenantName, application.SolutionUid.ToString("B")); Assert.IsNull(statisticsReport.CardinalityViolations, "Cardinality violations not null in report"); }
/// <summary> /// Initializes a new instance of the <see cref="StagingContext" /> class. /// </summary> public StagingContext( ) { Report = new StatisticsReport( ); }
public void GenerateReport(StatisticsReport report, string[] clientInfos) { var length = report.Samples.Length; var columns = report.BucketSize + 1; var rows = length / report.BucketSize; var ptm_data = new ChartData(columns, rows); // PingTimeMean Received; var pr_data = new ChartData(columns, rows); // Packets Received; var ps_data = new ChartData(columns, rows); // Packets Sent; var pd_data = new ChartData(columns, rows); // Packets Dropped or Stale; var br_data = new ChartData(columns, rows); // Bytes Received; var bs_data = new ChartData(columns, rows); // Bytes Sent; int it = 0; for (int row = 0; row < rows; row++) { var timestamp = report.Samples[it].Timestamp; ptm_data.Points[row * columns] = timestamp; pr_data.Points[row * columns] = timestamp; ps_data.Points[row * columns] = timestamp; pd_data.Points[row * columns] = timestamp; br_data.Points[row * columns] = timestamp; bs_data.Points[row * columns] = timestamp; for (int col = 1; col < columns; col++) { var sample = report.Samples[it++]; ptm_data.Points[row * columns + col] = sample.PingTimeMean; pr_data.Points[row * columns + col] = sample.ReceivedPackets; ps_data.Points[row * columns + col] = sample.SentPackets; pd_data.Points[row * columns + col] = sample.DroppedOrStalePackets; br_data.Points[row * columns + col] = sample.ReceivedBytes; bs_data.Points[row * columns + col] = sample.SentBytes; } } using (StreamWriter writer = new StreamWriter("c:\\Dump\\report.html")) { string ptmds = "Ping Times (Mean)"; string prds = "Packets Received"; string psds = "Packets Sent"; string pdds = "Packets Dropped or Stale"; string brds = "Bytes Received"; string bsds = "Bytes Sent"; writer.Write(header); writer.Write(GenerateBody(ptm_data, ptmds, 1, clientInfos)); writer.Write(GenerateBody(pr_data, prds, 2, clientInfos)); writer.Write(GenerateBody(ps_data, psds, 3, clientInfos)); writer.Write(GenerateBody(pd_data, pdds, 4, clientInfos)); writer.Write(GenerateBody(br_data, brds, 5, clientInfos)); writer.Write(GenerateBody(bs_data, bsds, 6, clientInfos)); writer.Write(footer); writer.Flush(); } ptm_data.Points.Dispose(); pr_data.Points.Dispose(); ps_data.Points.Dispose(); pd_data.Points.Dispose(); br_data.Points.Dispose(); bs_data.Points.Dispose(); }
void Start() { m_Manager = new SoakClientJobManager(SoakClientCount, SoakPacketsPerSecond, SoakPacketSize, SoakDuration); m_Report = new StatisticsReport(SoakClientCount); }
private int GetTargetDataCount(StatisticsReport report) { return(report.Counts.Count(pair => pair.Name.StartsWith("Copied") && pair.Name.EndsWith("Data"))); }
private int GetSourceDataCount(StatisticsReport report) { return(report.Counts.Count(pair => pair.Name.StartsWith("Current Application") && pair.Name.EndsWith("Data"))); }
public StatisticsReport GetReport(string measurement, string organization, DateTime?fromDate, DateTime?toDate) { TimeSpan ts = new TimeSpan(23, 59, 59); toDate = toDate.Value.Date + ts; StatisticsReport statisticsReport = new StatisticsReport(); bool organizationSelected = !string.IsNullOrEmpty(organization); var list = _dbContext.StatisticalData .Where(c => c.Measurement == measurement && (!organizationSelected || (organizationSelected && c.Organization == organization)) && (c.Date >= fromDate && c.Date <= toDate)) .GroupBy(x => x.Date) .Select(g => new { Date = g.Key, Count = g.Sum(x => x.Count) }).OrderBy(o => o.Date).ToList(); ReportResult reportResult = new ReportResult(); var data = new List <ReportResultData>(); ReportResultData resultData = new ReportResultData(); resultData = new ReportResultData { Label = measurement, TotalDataCount = 0, Values = new List <ReportResultDataValue>() }; foreach (var item in list) { resultData.Values.Add(new ReportResultDataValue { Key = item.Date.ToString(), Value = item.Count.ToString() }); } data.Add(resultData); reportResult.Data = data; if (list.Count > 0) { reportResult.TotalDataCount = list.Max(m => m.Count); } statisticsReport.ReportResult = reportResult; if (list.Count > 0) { statisticsReport.MinimumCount = list.Min(m => m.Count); } statisticsReport.MeasurementsAvailable = GetMeasurements(); statisticsReport.OrganizationsAvailable = GetOrganizations(); statisticsReport.MeasurementSelected = measurement; statisticsReport.OrganizationSelected = organization; statisticsReport.FromDate = fromDate; statisticsReport.ToDate = toDate; return(statisticsReport); }
public async Task <StatisticsReport> GetStatsAsync(StatisticEventType type, StatisticEventDimension dimension, DateTime start, int count, TimeInterval timeInterval, CancellationToken cancellationToken = default(CancellationToken)) { var current = start; var results = new StatisticsReport() { StartDate = start, Interval = timeInterval, Global = new StatisticMetric { }, Report = new List <StatisticsPeriodReport>() }; while (results.Report.Count() < count) { var currentEnd = start; switch (timeInterval) { case TimeInterval.Year: currentEnd = current.AddYears(1); break; case TimeInterval.Month: currentEnd = current.AddMonths(1); break; case TimeInterval.Day: currentEnd = current.AddDays(1); break; case TimeInterval.Hour: currentEnd = current.AddHours(1); break; case TimeInterval.Week: currentEnd = current.AddDays(7); break; } var filter = Filter.And( Filter.Gte(nameof(IOrder.Date), current), Filter.Lt(nameof(IOrder.Date), currentEnd), Filter.Ne(nameof(IOrder.Canceled), true), Filter.Eq(nameof(IOrder.OrderType), OrderType.Order) ); var periodResult = await FindAsync(filter, cancellationToken : cancellationToken); var dimensionsGroup = periodResult.GroupBy(r => _GetDimension(r, dimension) ?? ""); var perdimensions = dimensionsGroup.ToDictionary( group => group.Key, group => group.Select(g => new StatisticMetric() { Amount = g.Total, Sales = 1, Units = g.Units }).Aggregate((m1, m2) => m1 + m2) ); var allevents = periodResult.Select(g => new StatisticMetric() { Amount = g.Total, Sales = 1, Units = g.Units }).Where(e => e != null); var global = allevents.Any() ? allevents.Where(e => e != null).Aggregate((m1, m2) => m1 + m2) : new StatisticMetric(); var stats = new StatisticsPeriodReport { StartDate = current, EndDate = currentEnd, Global = global, Dimension = perdimensions }; results.Global += global; results.Report.Add(stats); current = currentEnd; } results.Currency = configuration.DefaultCurrency().Code; return(results); }
public void GenerateReport(StatisticsReport report, string[] clientInfos) { var length = report.Samples.Length; var columns = report.BucketSize + 1; var rows = length / report.BucketSize; var ptm_data = new ChartData(columns, rows); // PingTimeMean Received; var pr_data = new ChartData(columns, rows); // Packets Received; var ps_data = new ChartData(columns, rows); // Packets Sent; var pd_data = new ChartData(columns, rows); // Packets Dropped or Stale; var br_data = new ChartData(columns, rows); // Bytes Received; var bs_data = new ChartData(columns, rows); // Bytes Sent; var relsent_data = new ChartData(columns, rows); var relresent_data = new ChartData(columns, rows); var reldrop_data = new ChartData(columns, rows); var relrecv_data = new ChartData(columns, rows); var reldup_data = new ChartData(columns, rows); var relrtt_data = new ChartData(columns, rows); var relrtt_queue = new ChartData(columns, rows); var relrtt_age = new ChartData(columns, rows); var relrtt_max = new ChartData(columns, rows); var relrtt_smooth = new ChartData(columns, rows); var relrtt_proc = new ChartData(columns, rows); int it = 0; for (int row = 0; row < rows; row++) { var timestamp = report.Samples[it].Timestamp; ptm_data.Points[row * columns] = timestamp; pr_data.Points[row * columns] = timestamp; ps_data.Points[row * columns] = timestamp; pd_data.Points[row * columns] = timestamp; br_data.Points[row * columns] = timestamp; bs_data.Points[row * columns] = timestamp; relsent_data.Points[row * columns] = timestamp; relresent_data.Points[row * columns] = timestamp; reldrop_data.Points[row * columns] = timestamp; relrecv_data.Points[row * columns] = timestamp; reldup_data.Points[row * columns] = timestamp; relrtt_data.Points[row * columns] = timestamp; relrtt_queue.Points[row * columns] = timestamp; relrtt_age.Points[row * columns] = timestamp; relrtt_max.Points[row * columns] = timestamp; relrtt_smooth.Points[row * columns] = timestamp; relrtt_proc.Points[row * columns] = timestamp; for (int col = 1; col < columns; col++) { var sample = report.Samples[it++]; ptm_data.Points[row * columns + col] = sample.PingTimeMean; pr_data.Points[row * columns + col] = sample.ReceivedPackets; ps_data.Points[row * columns + col] = sample.SentPackets; pd_data.Points[row * columns + col] = sample.DroppedOrStalePackets; br_data.Points[row * columns + col] = sample.ReceivedBytes; bs_data.Points[row * columns + col] = sample.SentBytes; relsent_data.Points[row * columns + col] = sample.ReliableSent; relresent_data.Points[row * columns + col] = sample.ReliableResent; reldrop_data.Points[row * columns + col] = sample.ReliableDropped; relrecv_data.Points[row * columns + col] = sample.ReliableReceived; reldup_data.Points[row * columns + col] = sample.ReliableDuplicate; relrtt_data.Points[row * columns + col] = sample.ReliableRTT; relrtt_queue.Points[row * columns + col] = sample.ReliableResendQueue; relrtt_age.Points[row * columns + col] = sample.ReliableOldestResendPacketAge; relrtt_max.Points[row * columns + col] = sample.ReliableMaxRTT; relrtt_smooth.Points[row * columns + col] = sample.ReliableSRTT; relrtt_proc.Points[row * columns + col] = sample.ReliableMaxProcessingTime; } } using (StreamWriter writer = new StreamWriter(UnityEngine.Application.dataPath + "/../soaker_report.html")) { string ptmds = "Ping Times (Mean)"; string prds = "Packets Received"; string psds = "Packets Sent"; string pdds = "Packets Dropped or Stale"; string brds = "Bytes Received"; string bsds = "Bytes Sent"; writer.Write(header); writer.Write(GenerateBody(ptm_data, ptmds, 1, clientInfos)); writer.Write(GenerateBody(pr_data, prds, 2, clientInfos)); writer.Write(GenerateBody(ps_data, psds, 3, clientInfos)); writer.Write(GenerateBody(pd_data, pdds, 4, clientInfos)); writer.Write(GenerateBody(br_data, brds, 5, clientInfos)); writer.Write(GenerateBody(bs_data, bsds, 6, clientInfos)); writer.Write(GenerateBody(relsent_data, "Reliable Sent", 7, clientInfos)); writer.Write(GenerateBody(relrecv_data, "Reliable Received", 8, clientInfos)); writer.Write(GenerateBody(relresent_data, "Reliable Resent", 9, clientInfos)); writer.Write(GenerateBody(reldup_data, "Reliable Duplicate", 10, clientInfos)); writer.Write(GenerateBody(reldrop_data, "Reliable Dropped", 11, clientInfos)); writer.Write(GenerateBody(relrtt_data, "Reliable RTT", 12, clientInfos)); writer.Write(GenerateBody(relrtt_smooth, "Reliable Smooth RTT", 13, clientInfos)); writer.Write(GenerateBody(relrtt_max, "Reliable Max RTT", 14, clientInfos)); writer.Write(GenerateBody(relrtt_proc, "Reliable Max Processing Time", 15, clientInfos)); writer.Write(GenerateBody(relrtt_queue, "Reliable Resend Queue Size", 16, clientInfos)); writer.Write(GenerateBody(relrtt_age, "Reliable Oldest Resend Packet Age", 17, clientInfos)); writer.Write(footer); writer.Flush(); } ptm_data.Points.Dispose(); pr_data.Points.Dispose(); ps_data.Points.Dispose(); pd_data.Points.Dispose(); br_data.Points.Dispose(); bs_data.Points.Dispose(); reldup_data.Points.Dispose(); reldrop_data.Points.Dispose(); relrecv_data.Points.Dispose(); relsent_data.Points.Dispose(); relresent_data.Points.Dispose(); relrtt_data.Points.Dispose(); relrtt_queue.Points.Dispose(); relrtt_age.Points.Dispose(); relrtt_max.Points.Dispose(); relrtt_smooth.Points.Dispose(); relrtt_proc.Points.Dispose(); }
/// <summary> /// Initializes a new instance of the <see cref="ProcessingContext" /> class. /// </summary> public ProcessingContext( ) { Report = new StatisticsReport(WriteError, WriteWarning, WriteInfo); }