public MemoryMeasurementEvaluation(
			FromProcessMeasurement<MemoryStruct.IMemoryMeasurement> MemoryMeasurement,
			Accumulator.MemoryMeasurementAccumulator MemoryMeasurementAccu = null)
		{
			this.MemoryMeasurement = MemoryMeasurement?.Value;

			try
			{
				MemoryMeasurementParsed = MemoryMeasurement?.Value?.Parse();
			}
			catch (Exception Exception)
			{
				MemoryMeasurementParseException = Exception;
			}

			if (null == MemoryMeasurement)
			{
				return;
			}

			try
			{
				MemoryMeasurementAccu = MemoryMeasurementAccu ?? new Accumulator.MemoryMeasurementAccumulator();

				MemoryMeasurementAccu.Accumulate(MemoryMeasurement?.MapValue(t => MemoryMeasurementParsed));

				this.MemoryMeasurementAccumulation = MemoryMeasurementAccu;
			}
			catch (Exception Exception)
			{
				MemoryMeasurementAccuException = Exception;
			}
		}
示例#2
0
        public void AccumulatorTests_IfMultipleProductSeperated_ThenCorrectOutput()
        {
            //arrange
            var             sut       = new Accumulator();
            var             mockData  = CreateRowDataMock("P1", 1, 1, 10);
            var             mockData1 = CreateRowDataMock("P1", 1, 2, 30);
            var             mockData2 = CreateRowDataMock("P2", 1, 1, 20);
            var             mockData3 = CreateRowDataMock("P2", 1, 2, 10);
            List <IRowData> mockDatas = new List <IRowData>()
            {
                mockData.Object, mockData1.Object, mockData2.Object, mockData3.Object
            };

            //act
            var accumulated = sut.Accumulate(mockDatas);

            //assert
            List <double> accumulatedValues  = accumulated.Products.First().Values.ToList();
            List <double> accumulatedValues1 = accumulated.Products.Last().Values.ToList();

            Assert.AreEqual(3, accumulatedValues.Count);
            Assert.AreEqual(10, accumulatedValues[0]);
            Assert.AreEqual(40, accumulatedValues[1]);
            Assert.AreEqual(20, accumulatedValues1[0]);
            Assert.AreEqual(30, accumulatedValues1[1]);
        }
示例#3
0
        public void AccumulatorTests_IfRepeatedValue_ThenExceptionThrown()
        {
            //arrange
            var             sut       = new Accumulator();
            var             mockData  = CreateRowDataMock("P1", 1, 1, 10);
            var             mockData1 = CreateRowDataMock("P1", 1, 1, 20);
            List <IRowData> mockDatas = new List <IRowData>()
            {
                mockData.Object, mockData1.Object
            };
            bool exceptionThrown = false;

            //act

            try
            {
                var accumulated = sut.Accumulate(mockDatas);
            }
            catch (ArgumentException)
            {
                exceptionThrown = true;
            }
            //assert
            Assert.IsTrue(exceptionThrown);
        }
示例#4
0
        private double EvaluateInternal(ValueVector x, ValueVector y, int size)
        {
            Accumulator acc = CreateAccumulator();

            // error handling is as if the x is fully evaluated before y
            ErrorEval firstXerr      = null;
            ErrorEval firstYerr      = null;
            bool      accumlatedSome = false;
            double    result         = 0.0;

            for (int i = 0; i < size; i++)
            {
                ValueEval vx = x.GetItem(i);
                ValueEval vy = y.GetItem(i);
                if (vx is ErrorEval)
                {
                    if (firstXerr == null)
                    {
                        firstXerr = (ErrorEval)vx;
                        continue;
                    }
                }
                if (vy is ErrorEval)
                {
                    if (firstYerr == null)
                    {
                        firstYerr = (ErrorEval)vy;
                        continue;
                    }
                }
                // only count pairs if both elements are numbers
                if (vx is NumberEval && vy is NumberEval)
                {
                    accumlatedSome = true;
                    NumberEval nx = (NumberEval)vx;
                    NumberEval ny = (NumberEval)vy;
                    result += acc.Accumulate(nx.NumberValue, ny.NumberValue);
                }
                else
                {
                    // all other combinations of value types are silently ignored
                }
            }
            if (firstXerr != null)
            {
                throw new EvaluationException(firstXerr);
            }
            if (firstYerr != null)
            {
                throw new EvaluationException(firstYerr);
            }
            if (!accumlatedSome)
            {
                throw new EvaluationException(ErrorEval.DIV_ZERO);
            }
            return(result);
        }
示例#5
0
        private static void ConfirmXY(Accumulator acc, double[] xarr, double[] yarr,
                                      double expectedResult)
        {
            double result = 0.0;

            for (int i = 0; i < xarr.Length; i++)
            {
                result += acc.Accumulate(xarr[i], yarr[i]);
            }
            Assert.AreEqual(expectedResult, result, 0.0);
        }
示例#6
0
        /// <param name="assembly">The assembly of the namespace</param>
        /// <param name="namespace">The namespace to search</param>
        public NamespaceSuite(Assembly assembly, string @namespace)
        {
            Namespace = @namespace;
            var typeContainedInNamespace = assembly.GetTypes().FirstOrDefault(type => type.Namespace == Namespace);

            if (typeContainedInNamespace == null)
            {
                throw new ArgumentException(string.Format("Assembly \"{0}\" contains no types for namespace \"{1}\".", assembly, Namespace), "assembly");
            }

            AddTests(Accumulator.Accumulate(typeContainedInNamespace, Enumerable.Empty <IAccumulationFilter>(), new NullConfigurator()));
        }
        /// <summary>
        /// Add an item to the buffer. It is also added to the accumulator.
        /// If the buffer is at its capacity, the oldest item is removed from
        /// both the buffer and the accumulator.
        /// </summary>
        /// <param name="item"></param>
        public void Add(T item)
        {
            if (queue.Count >= queueCapacity)
            {
                queueAccumulator.Rotate(item, queue.Dequeue());
            }
            else
            {
                queueAccumulator.Accumulate(item);
            }

            queue.Enqueue(item);
        }
示例#8
0
        public void AccumulatorTests_IfSingleRow_ThenEndsAtSpecifiedDevelopement()
        {
            //arrange
            var             sut       = new Accumulator();
            var             mockData  = CreateRowDataMock("P1", 1, 1, 10);
            List <IRowData> mockDatas = new List <IRowData>()
            {
                mockData.Object
            };

            //act
            var accumulated = sut.Accumulate(mockDatas);

            //assert
            Assert.AreEqual(1, accumulated.Range.End);
        }
 CheckHistoryAction(int LastAction_, int Action_)
 {
     Action_ = base.CheckHistoryAction(LastAction_, Action_);
     if (((LastAction_ == Left) && (Action_ == Left)) || ((LastAction_ == Right) && (Action_ == Right)))
     {
         MoveForceAccumulator.Accumulate();
     }
     else
     {
         MoveForceAccumulator.Reset();
     }
     if ((LastAction_ == Attack) && (Action_ == Attack))
     {
         Action_ = NoAction;
     }
     return(Action_);
 }
示例#10
0
        public void AccumulatorTests_IfMaxValue_ThenOverflows()
        {
            //arrange
            var             sut       = new Accumulator();
            var             mockData  = CreateRowDataMock("P1", 1, 1, double.MaxValue);
            var             mockData1 = CreateRowDataMock("P1", 1, 2, double.MaxValue);
            List <IRowData> mockDatas = new List <IRowData>()
            {
                mockData.Object, mockData1.Object
            };

            //act
            var accumulated = sut.Accumulate(mockDatas);

            //assert
            List <double> accumulatedValues = accumulated.Products.Single().Values.ToList();

            Assert.AreNotEqual(double.MaxValue, accumulatedValues[1]);
        }
示例#11
0
        public void AccumulatorTests_Ifnegativevalue_ThenNegativeAccumulatedResult()
        {
            //arrange
            var             sut       = new Accumulator();
            var             mockData  = CreateRowDataMock("P1", 1, 1, -10);
            var             mockData1 = CreateRowDataMock("P1", 1, 2, 20);
            List <IRowData> mockDatas = new List <IRowData>()
            {
                mockData.Object, mockData1.Object
            };

            //act
            var accumulated = sut.Accumulate(mockDatas);

            //assert
            List <double> accumulatedValues = accumulated.Products.Single().Values.ToList();

            Assert.AreEqual(3, accumulatedValues.Count);
            Assert.AreEqual(-10, accumulatedValues[0]);
            Assert.AreEqual(10, accumulatedValues[1]);
        }
示例#12
0
        /// <summary>
        /// Specify that some bytes were transferred in a particular window.
        /// </summary>
        /// <param name="window">Number representing time, e.g. 1 = 100ms to 200ms, 2 = 200ms to 300ms, etc</param>
        /// <param name="value">Count of bytes transferred</param>
        public void Accumulate(long window, long value)
        {
            if (window < 0)
            {
                throw new ArgumentOutOfRangeException("window");
            }

            // Special case: initialize the top window on the first call to Accumulate()
            if (currentWindow == -1)
            {
                currentWindow = window;
            }

            // If trying to accumulate old data, put it in the current window
            if (window < currentWindow)
            {
                window = currentWindow;
            }

            // If these bytes are not in the current window, put the total bytes transferred
            // in the current window to the previous bytes queue
            if (window > currentWindow)
            {
                previousBytesTransferred.Add(currentBytesAccumulator.Total());
                currentBytesAccumulator.Clear();
                currentWindow++;
            }

            // If there is a gap between the current window and this window, enqueue
            // the appropriate number of empty windows
            if (window != currentWindow)
            {
                previousBytesTransferred.AddN(window - currentWindow);
                currentWindow = window;
            }

            // finally accumulate the bytes transferred
            currentBytesAccumulator.Accumulate(value);
        }
示例#13
0
        public void AccumulatorTests_IfGapsinData_ThenTreatAsValueIsZero()
        {
            //arrange
            var             sut       = new Accumulator();
            var             mockData  = CreateRowDataMock("P1", 1, 1, 10);
            var             mockData1 = CreateRowDataMock("P1", 2, 2, 20);
            List <IRowData> mockDatas = new List <IRowData>()
            {
                mockData.Object, mockData1.Object
            };

            //act
            var accumulated = sut.Accumulate(mockDatas);

            //assert
            List <double> accumulatedValues = accumulated.Products.Single().Values.ToList();

            Assert.AreEqual(3, accumulatedValues.Count);
            Assert.AreEqual(10, accumulatedValues[0]);
            Assert.AreEqual(10, accumulatedValues[1]);
            Assert.AreEqual(20, accumulatedValues[2]);
        }
示例#14
0
        public void AccumulatorTests_IfNoDataIn_ThenThrownException()
        {
            //arrange
            var sut = new Accumulator();

            List <IRowData> mockDatas = new List <IRowData>()
            {
            };
            bool exceptionThrown = false;

            //act
            try
            {
                var accumulated = sut.Accumulate(mockDatas);
            }
            catch (InvalidOperationException)
            {
                exceptionThrown = true;
            }
            //assert
            Assert.IsTrue(exceptionThrown);
        }
示例#15
0
        public void AccumulatorTests_If2ndProductis1st_Then2ndProductis1stOutput()
        {
            //arrange
            var             sut       = new Accumulator();
            var             mockData  = CreateRowDataMock("P2", 1, 1, 10);
            var             mockData1 = CreateRowDataMock("P1", 1, 1, 20);
            List <IRowData> mockDatas = new List <IRowData>()
            {
                mockData.Object, mockData1.Object
            };

            //act
            var accumulated = sut.Accumulate(mockDatas);

            //assert
            List <double> accumulatedValues  = accumulated.Products.First().Values.ToList();
            List <double> accumulatedValues1 = accumulated.Products.Last().Values.ToList();

            Assert.AreEqual(1, accumulatedValues.Count);
            Assert.AreEqual(10, accumulatedValues[0]);
            Assert.AreEqual(20, accumulatedValues1[0]);
        }
示例#16
0
 private static void ConfirmXY(Accumulator acc, double[] xarr, double[] yarr,
     double expectedResult)
 {
     double result = 0.0;
     for (int i = 0; i < xarr.Length; i++)
     {
         result += acc.Accumulate(xarr[i], yarr[i]);
     }
     Assert.AreEqual(expectedResult, result, 0.0);
 }
示例#17
0
 /// <summary>
 /// Gets weather (precipitation, and maximum and minimum temperatures) data for each day, and accumulates it
 /// </summary>
 private void ReadWeather()
 {
     metAccumulator.Accumulate(Weather.Rain, Weather.MinT, Weather.MaxT);
 }
示例#18
0
 public AssemblySuite(_Assembly assembly, IEnumerable <IAccumulationFilter> filters, ITestConfigurator configurator)
 {
     Assembly = assembly;
     Name     = assembly.GetName().Name;
     AddTests(Accumulator.Accumulate(assembly, filters, configurator));
 }