Example #1
0
        public Difference(string metric1, string metric2)
            : base(0)
        {
            _expression1 = MetricEvaluationContext.ParseExpression(metric1);
            _expression2 = MetricEvaluationContext.ParseExpression(metric2);

            Values = new double[2];
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="metricName">the metric definition string, such as "MA[40](BAR.CP)"</param>
        public GenericRuntimeMetric(string metricName)
        {
            if (string.IsNullOrWhiteSpace(metricName))
            {
                throw new ArgumentNullException();
            }

            _expression = MetricEvaluationContext.ParseExpression(metricName);
        }
Example #3
0
 /// <summary>
 /// Handles the AST node visit.
 /// </summary>
 /// <param name="astNode">AST node.</param>
 public override void Visit(IdentifierTermAstNode astNode)
 {
     if (astNode.Name.Equals("total-time"))
     {
         ExpressionData = new MetricTotalTime();
     }
     else
     {
         ExpressionData = new MetricNumericFunction(astNode.Name);
     }
 }
Example #4
0
 /// <summary>
 /// Handles the AST node visit.
 /// </summary>
 /// <param name="astNode">AST node.</param>
 public override void Visit(FunctionTermAstNode astNode)
 {
     if (astNode.Name.Equals("total-time"))
     {
         ExpressionData = new MetricTotalTime();
     }
     else
     {
         MetricNumericFunction function = new MetricNumericFunction(astNode.Name);
         astNode.Terms.ForEach(term => function.Terms.Add(MasterExporter.ToConstantTerm(term)));
         ExpressionData = function;
     }
 }
Example #5
0
        /// <summary>
        /// Handles the AST node visit.
        /// </summary>
        /// <param name="astNode">AST node.</param>
        public override void Visit(NumericOpAstNode astNode)
        {
            MetricExpressions arguments = new MetricExpressions();

            astNode.Arguments.ForEach(arg => arguments.Add(MasterExporter.ToMetricExpression(arg)));

            switch (astNode.Operator)
            {
            case Traits.NumericOperator.PLUS:
            {
                ExpressionData = new MetricPlus(arguments);
                break;
            }

            case Traits.NumericOperator.MINUS:
            {
                if (arguments.Count == 1)
                {
                    ExpressionData = new MetricUnaryMinus(arguments[0]);
                }
                else
                {
                    ExpressionData = new MetricMinus(arguments[0], arguments[1]);
                }
                break;
            }

            case Traits.NumericOperator.MUL:
            {
                ExpressionData = new MetricMultiply(arguments);
                break;
            }

            case Traits.NumericOperator.DIV:
            {
                ExpressionData = new MetricDivide(arguments[0], arguments[1]);
                break;
            }

            default:
            {
                Debug.Assert(false);
                break;
            }
            }
        }
Example #6
0
 /// <summary>
 /// Handles the AST node visit.
 /// </summary>
 /// <param name="astNode">AST node.</param>
 public override void Visit(MetricPreferenceViolationAstNode astNode)
 {
     ExpressionData = new MetricPreferenceViolation(astNode.Name);
 }
Example #7
0
 /// <summary>
 /// Handles the AST node visit.
 /// </summary>
 /// <param name="astNode">AST node.</param>
 public override void Visit(NumberTermAstNode astNode)
 {
     ExpressionData = new MetricNumber(astNode.Number);
 }
Example #8
0
 protected MetricBinaryOperator(MetricExpression operand1, MetricExpression operand2)
 {
     Operand1 = operand1;
     Operand2 = operand2;
 }
 protected MetricUnaryOperator(MetricExpression operand)
 {
     Operand = operand;
 }