Exemple #1
0
        /// <summary>
        /// Gets a human readable plain text of the QueryPreparationTimes (Please use monospace font).
        /// </summary>
        /// <param name="indentLevel">The indent / nesting level of the QueryPreparationTimes object.</param>
        /// <returns>A human readable plain text of the QueryPreparationTimes.</returns>
        public string ToTextString(int indentLevel = 0)
        {
            if (indentLevel == int.MaxValue)
            {
                throw new ArgumentOutOfRangeException("indentLevel", "input must be less than Int32.MaxValue");
            }

            StringBuilder stringBuilder = new StringBuilder();

            // Checked block is needed to suppress potential overflow warning ... even though I check it above
            checked
            {
                QueryMetricsUtils.AppendHeaderToStringBuilder(
                    stringBuilder,
                    QueryMetricsConstants.QueryPreparationTimesText,
                    indentLevel);

                QueryMetricsUtils.AppendMillisecondsToStringBuilder(
                    stringBuilder,
                    QueryMetricsConstants.QueryCompileTimeText,
                    this.QueryCompilationTime.TotalMilliseconds,
                    indentLevel + 1);

                QueryMetricsUtils.AppendMillisecondsToStringBuilder(
                    stringBuilder,
                    QueryMetricsConstants.LogicalPlanBuildTimeText,
                    this.LogicalPlanBuildTime.TotalMilliseconds,
                    indentLevel + 1);

                QueryMetricsUtils.AppendMillisecondsToStringBuilder(
                    stringBuilder,
                    QueryMetricsConstants.PhysicalPlanBuildTimeText,
                    this.PhysicalPlanBuildTime.TotalMilliseconds,
                    indentLevel + 1);

                QueryMetricsUtils.AppendMillisecondsToStringBuilder(
                    stringBuilder,
                    QueryMetricsConstants.QueryOptimizationTimeText,
                    this.QueryOptimizationTime.TotalMilliseconds,
                    indentLevel + 1);
            }

            return(stringBuilder.ToString());
        }
Exemple #2
0
        /// <summary>
        /// Gets a human readable plain text of the RuntimeExecutionTimes (Please use monospace font).
        /// </summary>
        /// <param name="indentLevel">The indent / nesting level of the RuntimeExecutionTimes.</param>
        /// <returns>A human readable plain text of the QueryMetrics.</returns>
        public string ToTextString(int indentLevel = 0)
        {
            if (indentLevel == int.MaxValue)
            {
                throw new ArgumentOutOfRangeException("indentLevel", "input must be less than Int32.MaxValue");
            }

            StringBuilder stringBuilder = new StringBuilder();

            // Checked block is needed to suppress potential overflow warning ... even though I check it above
            checked
            {
                QueryMetricsUtils.AppendHeaderToStringBuilder(
                    stringBuilder,
                    QueryMetricsConstants.RuntimeExecutionTimesText,
                    indentLevel);

                QueryMetricsUtils.AppendMillisecondsToStringBuilder(
                    stringBuilder,
                    QueryMetricsConstants.TotalExecutionTimeText,
                    this.QueryEngineExecutionTime.TotalMilliseconds,
                    indentLevel + 1);

                QueryMetricsUtils.AppendMillisecondsToStringBuilder(
                    stringBuilder,
                    QueryMetricsConstants.SystemFunctionExecuteTimeText,
                    this.SystemFunctionExecutionTime.TotalMilliseconds,
                    indentLevel + 1);

                QueryMetricsUtils.AppendMillisecondsToStringBuilder(
                    stringBuilder,
                    QueryMetricsConstants.UserDefinedFunctionExecutionTimeText,
                    this.UserDefinedFunctionExecutionTime.TotalMilliseconds,
                    indentLevel + 1);
            }

            return(stringBuilder.ToString());
        }
 public static void AppendNewlineToStringBuilder(StringBuilder stringBuilder)
 {
     QueryMetricsUtils.AppendHeaderToStringBuilder(stringBuilder, string.Empty, 0);
 }
        /// <summary>
        /// Gets a human readable plain text of the ClientSideMetrics (Please use monospace font).
        /// </summary>
        /// <param name="indentLevel">The indent / nesting level of the ClientSideMetrics.</param>
        /// <returns>A human readable plain text of the ClientSideMetrics.</returns>
        public string ToTextString(int indentLevel = 0)
        {
            if (indentLevel == int.MaxValue)
            {
                throw new ArgumentOutOfRangeException("indentLevel", "input must be less than Int32.MaxValue");
            }

            StringBuilder stringBuilder = new StringBuilder();

            checked
            {
                // Properties
                QueryMetricsUtils.AppendHeaderToStringBuilder(
                    stringBuilder,
                    QueryMetricsConstants.ClientSideQueryMetricsText,
                    indentLevel);
                QueryMetricsUtils.AppendCountToStringBuilder(
                    stringBuilder,
                    QueryMetricsConstants.RetriesText,
                    this.Retries,
                    indentLevel + 1);
                QueryMetricsUtils.AppendRUToStringBuilder(
                    stringBuilder,
                    QueryMetricsConstants.RequestChargeText,
                    this.RequestCharge,
                    indentLevel + 1);

                QueryMetricsUtils.AppendNewlineToStringBuilder(stringBuilder);

                // Building the table for fetch execution ranges
                QueryMetricsUtils.AppendHeaderToStringBuilder(stringBuilder, QueryMetricsConstants.FetchExecutionRangesText, 1);
                QueryMetricsUtils.AppendHeaderToStringBuilder(stringBuilder, PartitionExecutionTimelineTable.TopLine, 1);
                QueryMetricsUtils.AppendHeaderToStringBuilder(stringBuilder, PartitionExecutionTimelineTable.Header, 1);
                QueryMetricsUtils.AppendHeaderToStringBuilder(stringBuilder, PartitionExecutionTimelineTable.MiddleLine, 1);
                foreach (FetchExecutionRange fetchExecutionRange in this.FetchExecutionRanges.OrderBy(fetchExecutionRange => fetchExecutionRange.StartTime))
                {
                    QueryMetricsUtils.AppendHeaderToStringBuilder(
                        stringBuilder,
                        PartitionExecutionTimelineTable.GetRow(
                            fetchExecutionRange.PartitionId,
                            fetchExecutionRange.StartTime.ToUniversalTime().ToString("hh:mm:ss.ffffff"),
                            fetchExecutionRange.EndTime.ToUniversalTime().ToString("hh:mm:ss.ffffff"),
                            (fetchExecutionRange.EndTime - fetchExecutionRange.StartTime).TotalMilliseconds.ToString("0.00"),
                            fetchExecutionRange.NumberOfDocuments,
                            fetchExecutionRange.RetryCount),
                        1);
                }

                QueryMetricsUtils.AppendHeaderToStringBuilder(stringBuilder, PartitionExecutionTimelineTable.BottomLine, 1);

                QueryMetricsUtils.AppendNewlineToStringBuilder(stringBuilder);

                // Building the table for scheduling metrics
                QueryMetricsUtils.AppendHeaderToStringBuilder(stringBuilder, QueryMetricsConstants.SchedulingMetricsText, 1);
                QueryMetricsUtils.AppendHeaderToStringBuilder(stringBuilder, SchedulingMetricsTable.TopLine, 1);
                QueryMetricsUtils.AppendHeaderToStringBuilder(stringBuilder, SchedulingMetricsTable.Header, 1);
                QueryMetricsUtils.AppendHeaderToStringBuilder(stringBuilder, SchedulingMetricsTable.MiddleLine, 1);
                foreach (Tuple <string, SchedulingTimeSpan> partitionSchedulingTimeSpan in this.PartitionSchedulingTimeSpans.OrderBy(x => x.Item2.ResponseTime))
                {
                    string             partitionId        = partitionSchedulingTimeSpan.Item1;
                    SchedulingTimeSpan schedulingTimeSpan = partitionSchedulingTimeSpan.Item2;

                    QueryMetricsUtils.AppendHeaderToStringBuilder(
                        stringBuilder,
                        SchedulingMetricsTable.GetRow(
                            partitionId,
                            schedulingTimeSpan.ResponseTime.TotalMilliseconds.ToString("0.00"),
                            schedulingTimeSpan.RunTime.TotalMilliseconds.ToString("0.00"),
                            schedulingTimeSpan.WaitTime.TotalMilliseconds.ToString("0.00"),
                            schedulingTimeSpan.TurnaroundTime.TotalMilliseconds.ToString("0.00"),
                            schedulingTimeSpan.NumPreemptions),
                        1);
                }

                QueryMetricsUtils.AppendHeaderToStringBuilder(stringBuilder, SchedulingMetricsTable.BottomLine, 1);
            }

            return(stringBuilder.ToString());
        }