Add() public method

public Add ( double value ) : void
value double
return void
コード例 #1
0
        public void Add_CreatesAvgReading()
        {
            var sensor = new TimingSensor("test");
            sensor.Add(10.5);

            Assert.That(ReadingPublisher.Readings.Count, Is.EqualTo(1));

            Reading reading = null;
            ReadingPublisher.Readings.TryDequeue(out reading);
            Assert.That(reading.Data, Is.InstanceOf<AvgReadingData>());
        }
コード例 #2
0
        public void Add_CreatesAvgReadingWithCorrectName()
        {
            string sensorName = "test";
            var sensor = new TimingSensor(sensorName);
            sensor.Add(10.5);

            Assert.That(ReadingPublisher.Readings.Count, Is.EqualTo(1));

            Reading reading = null;
            ReadingPublisher.Readings.TryDequeue(out reading);
            Assert.That(reading.Data.Name, Is.EqualTo(sensorName + " - Avg ms"));
        }
コード例 #3
0
        // Record time spent executing the method
        public override void OnInvoke(MethodInterceptionArgs eventArgs)
        {
            string metricName = GetMetricName(
                            eventArgs.Method.DeclaringType,
                            eventArgs.Method.Name,
                            eventArgs.Method.IsGenericMethod,
                            eventArgs.Method.GetGenericArguments());

            var sensor = new TimingSensor(metricName) { FeatureName = _featureName, FeatureGroup = _featureGroup };
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            // continue with method invocation
            eventArgs.Proceed();

            stopwatch.Stop();

            sensor.Add(stopwatch.ElapsedMilliseconds);
        }
コード例 #4
0
 public void OnActionExecuted(ActionExecutedContext filterContext)
 {
     _watch.Stop();
     TimingSensor timingSensor = new TimingSensor(GetReadingName(filterContext.Controller, filterContext.ActionDescriptor.ActionName));
     timingSensor.Add(_watch.ElapsedMilliseconds);
 }