public void RecordEventMetricReflectionDataRangeTest()
        {
            UserEventObject myDataObject = new UserEventObject("Data Range Test");

            //warm up the object just to get rid of first hit performance
            EventMetric.Register(myDataObject);
            EventMetric.Write(myDataObject);

            //and we're going to write out a BUNCH of samples
            Trace.TraceInformation("Starting reflection data range test");
            DateTime curTime = DateTime.Now;

            //We have to limit ourselves to 32000 samples to stay within short.
            for (short curSample = 0; curSample < 32000; curSample++)
            {
                //we have a LOT of numbers we need to set to increment this object.
                myDataObject.SetValues(curSample, 32000);  //sets all of the numerics

                //and write it out again just for kicks
                EventMetric.Write(myDataObject);
            }
            TimeSpan duration = DateTime.Now - curTime;

            Trace.TraceInformation("Completed reflection data range test in {0} milliseconds for 32,000 samples", duration.TotalMilliseconds);

            Log.Verbose(LogWriteMode.WaitForCommit, "Test.Agent.Metrics.EventMetric.Attributes", "Event Metrics performance test flush", null);
        }
        public void RecordEventMetricReflection()
        {
            UserEventObject myDataObject = new UserEventObject(null);

            EventMetric.Register(myDataObject);

            EventMetricDefinition metricDefinition;

            Assert.IsTrue(EventMetricDefinition.TryGetValue(typeof(UserEventObject), out metricDefinition));

            EventMetricDefinition.Write(myDataObject);

            // Now try it with inheritance and interfaces in the mix.

            UserMultipleEventObject bigDataObject = new UserMultipleEventObject(null);

            EventMetric.Register(bigDataObject);
            // There's no event at the top level, so this lookup should fail.
            Assert.IsFalse(EventMetricDefinition.TryGetValue(typeof(UserMultipleEventObject), out metricDefinition));
            // Now check for interfaces...
            Assert.IsTrue(EventMetricDefinition.TryGetValue(typeof(IEventMetricOne), out metricDefinition));
            Assert.IsTrue(EventMetricDefinition.TryGetValue(typeof(IEventMetricTwo), out metricDefinition));
            Assert.IsTrue(EventMetricDefinition.TryGetValue(typeof(IEventMetricThree), out metricDefinition));
            Assert.IsTrue(EventMetricDefinition.TryGetValue(typeof(IEventMetricFour), out metricDefinition));

            // And sample all of them on the big object with a single call...

            EventMetric.Write(bigDataObject);
        }
        public void PrettySampleDataOverTimeTest()
        {
            UserEventObject myDataObject = new UserEventObject("Pretty Data");

            EventMetric.Register(myDataObject);

            //do a set of 20 samples with a gap between each.
            for (short curSample = 0; curSample < 20; curSample++)
            {
                myDataObject.SetValues(curSample);
                EventMetric.Write(myDataObject);

                //now sleep for a little to make a nice gap.  This has to be >> 16 ms to show a reasonable gap.
                Thread.Sleep(200);
            }
        }