Exemple #1
0
        public void TestParseStringWithTrailingUnknownField()
        {
            string         delimitedString = $"thisIsNotAKnownField=asdf";
            BackendMetrics expected        = new BackendMetrics(
                default(long),
                default(long),
                default(long),
                default(long),
                default(double),
                default(TimeSpan),
                new QueryPreparationTimes(
                    default(TimeSpan),
                    default(TimeSpan),
                    default(TimeSpan),
                    default(TimeSpan)),
                default(TimeSpan),
                default(TimeSpan),
                default(TimeSpan),
                new RuntimeExecutionTimes(
                    default(TimeSpan),
                    default(TimeSpan),
                    default(TimeSpan)),
                default(TimeSpan));

            BackendMetricsTests.ValidateParse(delimitedString, expected);
        }
Exemple #2
0
        public void TestParseStringWithMissingFields()
        {
            TimeSpan totalExecutionTime = TimeSpan.FromTicks((long)(TimeSpan.TicksPerMillisecond * 33.67));
            string   delimitedString    = $"totalExecutionTimeInMs={totalExecutionTime.TotalMilliseconds}";

            BackendMetrics expected = new BackendMetrics(
                default(long),
                default(long),
                default(long),
                default(long),
                default(double),
                totalExecutionTime,
                new QueryPreparationTimes(
                    default(TimeSpan),
                    default(TimeSpan),
                    default(TimeSpan),
                    default(TimeSpan)),
                default(TimeSpan),
                default(TimeSpan),
                default(TimeSpan),
                new RuntimeExecutionTimes(
                    default(TimeSpan),
                    default(TimeSpan),
                    default(TimeSpan)),
                default(TimeSpan));

            BackendMetricsTests.ValidateParse(delimitedString, expected);
        }
Exemple #3
0
        public void TestAccumulator()
        {
            BackendMetrics.Accumulator accumulator = new BackendMetrics.Accumulator();
            accumulator = accumulator.Accumulate(MockBackendMetrics);
            accumulator = accumulator.Accumulate(MockBackendMetrics);

            BackendMetrics backendMetricsFromAddition = BackendMetrics.Accumulator.ToBackendMetrics(accumulator);
            BackendMetrics expected = new BackendMetrics(
                retrievedDocumentCount * 2,
                retrievedDocumentSize * 2,
                outputDocumentCount * 2,
                outputDocumentSize * 2,
                indexHitRatio,
                totalExecutionTime * 2,
                new QueryPreparationTimes(
                    queryCompileTime * 2,
                    logicalPlanBuildTime * 2,
                    physicalPlanBuildTime * 2,
                    queryOptimizationTime * 2),
                indexLookupTime * 2,
                documentLoadTime * 2,
                vmExecutionTime * 2,
                new RuntimeExecutionTimes(
                    (totalExecutionTime - systemFunctionExecuteTime - userFunctionExecuteTime) * 2,
                    systemFunctionExecuteTime * 2,
                    userFunctionExecuteTime * 2),
                documentWriteTime * 2);

            BackendMetricsTests.ValidateBackendMetricsEquals(expected, backendMetricsFromAddition);
        }
Exemple #4
0
 public void TestParseEmptyString()
 {
     BackendMetricsTests.ValidateParse(string.Empty, BackendMetrics.Empty);
 }
Exemple #5
0
 public void TestParse()
 {
     BackendMetricsTests.ValidateParse(delimitedString, MockBackendMetrics);
 }
Exemple #6
0
 private static void ValidateParse(string delimitedString, BackendMetrics expected)
 {
     Assert.IsTrue(BackendMetricsParser.TryParse(delimitedString, out BackendMetrics actual));
     BackendMetricsTests.ValidateBackendMetricsEquals(expected, actual);
 }