/// <summary> /// Creates a new QueryMetrics from the backend delimited string and ClientSideMetrics. /// </summary> /// <param name="delimitedString">The backend delimited string to deserialize from.</param> /// <param name="clientSideMetrics">The additional client side metrics.</param> /// <returns>A new QueryMetrics.</returns> internal static QueryMetrics CreateFromDelimitedStringAndClientSideMetrics(string delimitedString, ClientSideMetrics clientSideMetrics) { Dictionary <string, double> metrics = QueryMetricsUtils.ParseDelimitedString(delimitedString); double indexHitRatio; double retrievedDocumentCount; metrics.TryGetValue(QueryMetricsConstants.IndexHitRatio, out indexHitRatio); metrics.TryGetValue(QueryMetricsConstants.RetrievedDocumentCount, out retrievedDocumentCount); long indexHitCount = (long)(indexHitRatio * retrievedDocumentCount); double outputDocumentCount; metrics.TryGetValue(QueryMetricsConstants.OutputDocumentCount, out outputDocumentCount); double outputDocumentSize; metrics.TryGetValue(QueryMetricsConstants.OutputDocumentSize, out outputDocumentSize); double retrievedDocumentSize; metrics.TryGetValue(QueryMetricsConstants.RetrievedDocumentSize, out retrievedDocumentSize); TimeSpan totalQueryExecutionTime = QueryMetricsUtils.TimeSpanFromMetrics(metrics, QueryMetricsConstants.TotalQueryExecutionTimeInMs); return(new QueryMetrics( (long)retrievedDocumentCount, (long)retrievedDocumentSize, (long)outputDocumentCount, (long)outputDocumentSize, indexHitCount, totalQueryExecutionTime, QueryPreparationTimes.CreateFromDelimitedString(delimitedString), QueryMetricsUtils.TimeSpanFromMetrics(metrics, QueryMetricsConstants.IndexLookupTimeInMs), QueryMetricsUtils.TimeSpanFromMetrics(metrics, QueryMetricsConstants.DocumentLoadTimeInMs), QueryMetricsUtils.TimeSpanFromMetrics(metrics, QueryMetricsConstants.VMExecutionTimeInMs), RuntimeExecutionTimes.CreateFromDelimitedString(delimitedString), QueryMetricsUtils.TimeSpanFromMetrics(metrics, QueryMetricsConstants.DocumentWriteTimeInMs), clientSideMetrics)); }
/// <summary> /// Creates a new QueryPreparationTimes from the backend delimited string. /// </summary> /// <param name="delimitedString">The backend delimited string to deserialize from.</param> /// <returns>A new QueryPreparationTimes from the backend delimited string.</returns> internal static QueryPreparationTimes CreateFromDelimitedString(string delimitedString) { Dictionary <string, double> metrics = QueryMetricsUtils.ParseDelimitedString(delimitedString); return(new QueryPreparationTimes( QueryMetricsUtils.TimeSpanFromMetrics(metrics, QueryMetricsConstants.QueryCompileTimeInMs), QueryMetricsUtils.TimeSpanFromMetrics(metrics, QueryMetricsConstants.LogicalPlanBuildTimeInMs), QueryMetricsUtils.TimeSpanFromMetrics(metrics, QueryMetricsConstants.PhysicalPlanBuildTimeInMs), QueryMetricsUtils.TimeSpanFromMetrics(metrics, QueryMetricsConstants.QueryOptimizationTimeInMs))); }
/// <summary> /// Creates a new RuntimeExecutionTimes from the backend delimited string. /// </summary> /// <param name="delimitedString">The backend delimited string to deserialize from.</param> /// <returns>A new RuntimeExecutionTimes from the backend delimited string.</returns> internal static RuntimeExecutionTimes CreateFromDelimitedString(string delimitedString) { Dictionary <string, double> metrics = QueryMetricsUtils.ParseDelimitedString(delimitedString); TimeSpan vmExecutionTime = QueryMetricsUtils.TimeSpanFromMetrics( metrics, QueryMetricsConstants.VMExecutionTimeInMs); TimeSpan indexLookupTime = QueryMetricsUtils.TimeSpanFromMetrics( metrics, QueryMetricsConstants.IndexLookupTimeInMs); TimeSpan documentLoadTime = QueryMetricsUtils.TimeSpanFromMetrics( metrics, QueryMetricsConstants.DocumentLoadTimeInMs); TimeSpan documentWriteTime = QueryMetricsUtils.TimeSpanFromMetrics( metrics, QueryMetricsConstants.DocumentWriteTimeInMs); return(new RuntimeExecutionTimes( vmExecutionTime - indexLookupTime - documentLoadTime - documentWriteTime, QueryMetricsUtils.TimeSpanFromMetrics(metrics, QueryMetricsConstants.SystemFunctionExecuteTimeInMs), QueryMetricsUtils.TimeSpanFromMetrics(metrics, QueryMetricsConstants.UserDefinedFunctionExecutionTimeInMs))); }