Beispiel #1
0
        private void WritePartitionExecutionTimeline(ClientSideMetrics clientSideMetrics)
        {
            this.WriteBeforePartitionExecutionTimeline();

            foreach (FetchExecutionRange fetchExecutionRange in clientSideMetrics.FetchExecutionRanges.OrderBy(fetchExecutionRange => fetchExecutionRange.StartTime))
            {
                this.WriteFetchExecutionRange(fetchExecutionRange);
            }

            this.WriteAfterPartitionExecutionTimeline();
        }
Beispiel #2
0
        private void WriteClientSideMetrics(ClientSideMetrics clientSideMetrics)
        {
            this.WriteBeforeClientSideMetrics();

            this.WriteRetries(clientSideMetrics.Retries);
            this.WriteRequestCharge(clientSideMetrics.RequestCharge);
            this.WritePartitionExecutionTimeline(clientSideMetrics);
            this.WriteSchedulingMetrics(clientSideMetrics);

            this.WriteAfterClientSideMetrics();
        }
Beispiel #3
0
        private void WriteSchedulingMetrics(ClientSideMetrics clientSideMetrics)
        {
            this.WriteBeforeSchedulingMetrics();

            foreach (Tuple <string, SchedulingTimeSpan> partitionSchedulingTimeSpan in clientSideMetrics.PartitionSchedulingTimeSpans.OrderBy(x => x.Item2.ResponseTime))
            {
                string             partitionId        = partitionSchedulingTimeSpan.Item1;
                SchedulingTimeSpan schedulingTimeSpan = partitionSchedulingTimeSpan.Item2;

                this.WritePartitionSchedulingTimeSpan(partitionId, schedulingTimeSpan);
            }

            this.WriteAfterSchedulingMetrics();
        }
Beispiel #4
0
        internal QueryMetrics(
            long retrievedDocumentCount,
            long retrievedDocumentSize,
            long outputDocumentCount,
            long outputDocumentSize,
            long indexHitDocumentCount,
            IndexUtilizationInfo indexUtilizationInfo,
            TimeSpan totalQueryExecutionTime,
            QueryPreparationTimes queryPreparationTimes,
            TimeSpan indexLookupTime,
            TimeSpan documentLoadTime,
            TimeSpan vmExecutionTime,
            RuntimeExecutionTimes runtimeExecutionTimes,
            TimeSpan documentWriteTime,
            ClientSideMetrics clientSideMetrics)
        {
            if (queryPreparationTimes == null)
            {
                throw new ArgumentNullException($"{nameof(queryPreparationTimes)} can not be null.");
            }

            if (runtimeExecutionTimes == null)
            {
                throw new ArgumentNullException($"{nameof(runtimeExecutionTimes)} can not be null.");
            }

            if (clientSideMetrics == null)
            {
                throw new ArgumentNullException($"{nameof(clientSideMetrics)} can not be null.");
            }

            this.retrievedDocumentCount  = retrievedDocumentCount;
            this.retrievedDocumentSize   = retrievedDocumentSize;
            this.outputDocumentCount     = outputDocumentCount;
            this.outputDocumentSize      = outputDocumentSize;
            this.indexHitDocumentCount   = indexHitDocumentCount;
            this.indexUtilizationInfo    = indexUtilizationInfo;
            this.totalQueryExecutionTime = totalQueryExecutionTime;
            this.queryPreparationTimes   = queryPreparationTimes;
            this.indexLookupTime         = indexLookupTime;
            this.documentLoadTime        = documentLoadTime;
            this.vmExecutionTime         = vmExecutionTime;
            this.runtimeExecutionTimes   = runtimeExecutionTimes;
            this.documentWriteTime       = documentWriteTime;
            this.clientSideMetrics       = clientSideMetrics;
            this.queryEngineTimes        = new QueryEngineTimes(indexLookupTime, documentLoadTime, vmExecutionTime, documentWriteTime, runtimeExecutionTimes);
        }
Beispiel #5
0
        /// <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="indexUtilization">The index utilization from the backend</param>
        /// <param name="clientSideMetrics">The additional client side metrics.</param>
        /// <returns>A new QueryMetrics.</returns>
        internal static QueryMetrics CreateFromDelimitedStringAndClientSideMetrics(string delimitedString, string indexUtilization, ClientSideMetrics clientSideMetrics)
        {
            Dictionary <string, double> metrics = QueryMetricsUtils.ParseDelimitedString(delimitedString);

            metrics.TryGetValue(QueryMetricsConstants.IndexHitRatio, out double indexHitRatio);
            metrics.TryGetValue(QueryMetricsConstants.RetrievedDocumentCount, out double retrievedDocumentCount);
            long indexHitCount = (long)(indexHitRatio * retrievedDocumentCount);

            metrics.TryGetValue(QueryMetricsConstants.OutputDocumentCount, out double outputDocumentCount);
            metrics.TryGetValue(QueryMetricsConstants.OutputDocumentSize, out double outputDocumentSize);
            metrics.TryGetValue(QueryMetricsConstants.RetrievedDocumentSize, out double retrievedDocumentSize);
            TimeSpan totalQueryExecutionTime = QueryMetricsUtils.TimeSpanFromMetrics(metrics, QueryMetricsConstants.TotalQueryExecutionTimeInMs);

            IndexUtilizationInfo.TryCreateFromDelimitedString(indexUtilization, out IndexUtilizationInfo indexUtilizationInfo);
            return(new QueryMetrics(
                       (long)retrievedDocumentCount,
                       (long)retrievedDocumentSize,
                       (long)outputDocumentCount,
                       (long)outputDocumentSize,
                       indexHitCount,
                       indexUtilizationInfo,
                       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));
        }