Beispiel #1
0
        public void SampledMetricsByAttributesPerformanceTest()
        {
            SampledMetric.Register(typeof(UserPerformanceObject));
            Trace.TraceInformation("Sampled metrics registered by attributes.");

            UserPerformanceObject sampledObject = new UserPerformanceObject("AttributesPerformanceTest", 25, 100);

            //first, lets get everything to flush so we have our best initial state.
            Log.Information(LogWriteMode.WaitForCommit, "Test.Agent.Metrics.Performance", "Preparing for Test", "Flushing queue");

            //now that we know it's flushed everything, lets do our timed loop.
            DateTimeOffset startTime = DateTimeOffset.UtcNow;

            for (int curMessage = 0; curMessage < LoopsPerSampledTest; curMessage++)
            {
                SampledMetricDefinition.Write(sampledObject);
            }
            DateTimeOffset messageEndTime = DateTimeOffset.UtcNow;

            //one wait for commit message to force the buffer to flush.
            Log.Information(LogWriteMode.WaitForCommit, "Test.Agent.Metrics.Performance", "Waiting for Samples to Commit", null);

            //and store off our time
            DateTimeOffset endTime = DateTimeOffset.UtcNow;

            TimeSpan  testDuration    = endTime - startTime;
            TimeSpan  loopDuration    = messageEndTime - startTime;
            const int messagesPerTest = LoopsPerSampledTest * MessagesPerSampledLoop;

            Trace.TraceInformation("Sampled Metrics by Attributes Test committed {0:N0} samples in {1:F3} ms (average {2:F4} ms per message).  Average loop time {3:F4} ms ({4} samples per loop) and final flush time {5:F3} ms.",
                                   messagesPerTest, testDuration.TotalMilliseconds, (testDuration.TotalMilliseconds / messagesPerTest),
                                   (loopDuration.TotalMilliseconds / LoopsPerSampledTest), MessagesPerSampledLoop,
                                   (endTime - messageEndTime).TotalMilliseconds);
        }
Beispiel #2
0
        public void EventMetricsByAttributesPerformanceTest()
        {
            EventMetric.Register(typeof(UserPerformanceObject));
            Trace.TraceInformation("Event metrics registered by attributes.");

            UserPerformanceObject eventObject    = new UserPerformanceObject("AttributesPerformanceTest");
            DateTimeOffset        operationStart = DateTimeOffset.UtcNow;
            DateTimeOffset        operationEnd   = operationStart.AddMilliseconds(1234);

            eventObject.SetEventData(@"C:\Dummy\File\Name.txt", UserFileOperation.Write, operationStart, operationEnd);

            //first, lets get everything to flush so we have our best initial state.
            Log.Information(LogWriteMode.WaitForCommit, "Test.Agent.Metrics.Performance", "Preparing for Test", "Flushing queue");

            //now that we know it's flushed everything, lets do our timed loop.
            DateTimeOffset startTime = DateTimeOffset.UtcNow;

            for (int curMessage = 0; curMessage < LoopsPerEventTest; curMessage++)
            {
                EventMetricDefinition.Write(eventObject);
            }
            DateTimeOffset messageEndTime = DateTimeOffset.UtcNow;

            //one wait for commit message to force the buffer to flush.
            Log.Information(LogWriteMode.WaitForCommit, "Test.Agent.Metrics.Performance", "Waiting for Samples to Commit", null);

            //and store off our time
            DateTimeOffset endTime = DateTimeOffset.UtcNow;

            TimeSpan  testDuration    = endTime - startTime;
            TimeSpan  loopDuration    = messageEndTime - startTime;
            const int messagesPerTest = LoopsPerEventTest * MessagesPerEventLoop;

            Trace.TraceInformation("Event Metrics by Attributes Test committed {0:N0} events in {1:F3} ms (average {2:F4} ms per message).  Average loop time {3:F4} ms ({4} values per message) and final flush time {5:F3} ms.",
                                   messagesPerTest, testDuration.TotalMilliseconds, (testDuration.TotalMilliseconds / messagesPerTest),
                                   (loopDuration.TotalMilliseconds / LoopsPerEventTest), ValuesPerEventMessage,
                                   (endTime - messageEndTime).TotalMilliseconds);
        }