Codeunit 1926 Profiling Chart Helper
src/System Application/App/Performance Profiler/src/ProfilingChartHelper.Codeunit.al83 lines, Copyright (c) Microsoft Corporation. MIT
// ------------------------------------------------------------------------------------------------// Copyright (c) Microsoft Corporation. All rights reserved.// Licensed under the MIT License. See License.txt in the project root for license information.// ------------------------------------------------------------------------------------------------namespace System.Tooling;using System.Integration;using System.Visualization;codeunit 1926 "Profiling Chart Helper"{ Access = Internal; InherentEntitlements = X; InherentPermissions = X; var BusinessChart: Codeunit "Business Chart"; DurationTxt: Label 'Duration (milliseconds)'; /// <summary> /// Gets the dictionary with aggregation type identifiers as keys, and aggregated self time / full time as values. /// </summary> /// <param name="ProfilingAggregationType">The aggregation type.</param> /// <param name="AggregateBySelfTime">True if aggregation should be performed over self time, false indicates that the aggregation should be made over full time.</param> /// <param name="ChartLabels">The labels for the chart.</param> /// <param name="ChartValues">The measure values associated with the labels.</param> /// <remarks>ProfilingDataProcessor must be initialized for this method to work.</remarks> procedure GetChartData(ProfilingAggregationType: Enum "Profiling Aggregation Type"; AggregateBySelfTime: Boolean; ChartLabels: List of [Text]; ChartValues: List of [Integer]) var TempAggregatedProfilingNode: Record "Profiling Node"; ProfilingDataProcessor: Codeunit "Profiling Data Processor"; Identifier: Text; begin if AggregateBySelfTime then begin ProfilingDataProcessor.GetSelfTimeAggregate(TempAggregatedProfilingNode, ProfilingAggregationType); TempAggregatedProfilingNode.SetCurrentKey("Self Time"); end else begin ProfilingDataProcessor.GetFullTimeAggregate(TempAggregatedProfilingNode, ProfilingAggregationType); TempAggregatedProfilingNode.SetCurrentKey("Full Time"); end; TempAggregatedProfilingNode.Ascending(false); if TempAggregatedProfilingNode.FindSet() then repeat Identifier := ProfilingDataProcessor.GetUniqueIdentifierByAggregationType(TempAggregatedProfilingNode, ProfilingAggregationType); ChartLabels.Add(Identifier); if AggregateBySelfTime then ChartValues.Add(TempAggregatedProfilingNode."Self Time") else ChartValues.Add(TempAggregatedProfilingNode."Full Time") until TempAggregatedProfilingNode.Next() = 0; end; /// <summary> /// Updates the contents of the business chart control add-in for performance profiler charts. /// </summary> /// <param name="BusinessChartControlAddIn">The business chart control add-in</param> /// <param name="ProfilingAggregationType">The desired aggregation type for the chart.</param> /// <param name="BusinessChartType">The business chart type</param> /// <param name="AggregateBySelfTime">Specifies if the aggregation should be made over self-time or full time.</param> procedure UpdateData(BusinessChartControlAddIn: ControlAddIn BusinessChart; ProfilingAggregationType: Enum "Profiling Aggregation Type"; BusinessChartType: Enum "Business Chart Type"; AggregateBySelfTime: Boolean) var Index: Integer; ChartLabels: List of [Text]; ChartValues: List of [Integer]; begin GetChartData(ProfilingAggregationType, AggregateBySelfTime, ChartLabels, ChartValues); BusinessChart.Initialize(); BusinessChart.AddMeasure(DurationTxt, 1, Enum::"Business Chart Data Type"::Integer, BusinessChartType); BusinessChart.SetXDimension(Format(ProfilingAggregationType), Enum::"Business Chart Data Type"::String); for Index := 1 to ChartLabels.Count() do begin BusinessChart.AddDataRowWithXDimension(ChartLabels.Get(Index)); BusinessChart.SetValue(0, Index - 1, ChartValues.Get(Index)); end; BusinessChart.Update(BusinessChartControlAddIn); end;}