Exemplo n.º 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());
        }
Exemplo n.º 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());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets a human readable plain text of the QueryMetrics (Please use monospace font).
        /// </summary>
        /// <param name="indentLevel">The level of nesting / indenting of this object.</param>
        /// <returns>A human readable plain text of the QueryMetrics.</returns>
        internal 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
            {
                // Top level properties
                QueryMetricsUtils.AppendCountToStringBuilder(
                    stringBuilder,
                    QueryMetricsConstants.RetrievedDocumentCountText,
                    this.RetrievedDocumentCount,
                    indentLevel);

                QueryMetricsUtils.AppendBytesToStringBuilder(
                    stringBuilder,
                    QueryMetricsConstants.RetrievedDocumentSizeText,
                    this.RetrievedDocumentSize,
                    indentLevel);

                QueryMetricsUtils.AppendCountToStringBuilder(
                    stringBuilder,
                    QueryMetricsConstants.OutputDocumentCountText,
                    this.OutputDocumentCount,
                    indentLevel);

                QueryMetricsUtils.AppendBytesToStringBuilder(
                    stringBuilder,
                    QueryMetricsConstants.OutputDocumentSizeText,
                    this.OutputDocumentSize,
                    indentLevel);

                QueryMetricsUtils.AppendPercentageToStringBuilder(
                    stringBuilder,
                    QueryMetricsConstants.IndexUtilizationText,
                    this.IndexHitRatio,
                    indentLevel);

                QueryMetricsUtils.AppendMillisecondsToStringBuilder(
                    stringBuilder,
                    QueryMetricsConstants.TotalQueryExecutionTimeText,
                    this.TotalQueryExecutionTime.TotalMilliseconds,
                    indentLevel);

                // QueryPreparationTimes
                stringBuilder.Append(this.QueryPreparationTimes.ToTextString(indentLevel + 1));

                QueryMetricsUtils.AppendMillisecondsToStringBuilder(
                    stringBuilder,
                    QueryMetricsConstants.IndexLookupTimeText,
                    this.IndexLookupTime.TotalMilliseconds,
                    indentLevel + 1);

                QueryMetricsUtils.AppendMillisecondsToStringBuilder(
                    stringBuilder,
                    QueryMetricsConstants.DocumentLoadTimeText,
                    this.DocumentLoadTime.TotalMilliseconds,
                    indentLevel + 1);

                // VM Execution Time is not emitted since the user does not have any context

                // RuntimesExecutionTimes
                stringBuilder.Append(this.RuntimeExecutionTimes.ToTextString(indentLevel + 1));

                QueryMetricsUtils.AppendMillisecondsToStringBuilder(
                    stringBuilder,
                    QueryMetricsConstants.WriteOutputTimeText,
                    this.DocumentWriteTime.TotalMilliseconds,
                    indentLevel + 1);

                // Client Side Metrics
                stringBuilder.Append(this.ClientSideMetrics.ToTextString(indentLevel + 1));

                // Activity Ids
                QueryMetricsUtils.AppendActivityIdsToStringBuilder(stringBuilder, QueryMetricsConstants.ActivityIds, this.ActivityIds, indentLevel);
            }

            return(stringBuilder.ToString());
        }