示例#1
0
        public MathExpresionEngineBench()
        {
            _expresionsToTest = new Dictionary <string, double>
            {
                { "1.0*1.0", 1d },
                { "2^5", 32d },
                { "2^(5*(3-2))", 32d },
                { "2^(5*3)", 32768d },
                { "(2+6)*8-(5*(6-9))", 79d },
                { "(2+6)*8", 64d },
                { "8*5", 40d },
                { "25+35-28+40-80+101+25+36+47+25", 226d },
                { "225+50+87-568-987", -1193d },
                { "225+50+87-568-987*8", -8102d }
            };

            var context = new Flee.PublicTypes.ExpressionContext();

            _compiledFlee = _expresionsToTest.Select(expr => context.CompileGeneric <double>(expr.Key)).ToList();


            var contex2 = new MathExpresionEngine.Context();

            _pseudoCompiledExpressionContext = _expresionsToTest.Select(expr =>
            {
                var parser   = new MathExpresionEngine.Parser(expr.Key, contex2);
                var exprTree = parser.GetExpresionTree();
                return(exprTree);
            }).ToList();
        }