static void RunBenchmark(BenchmarkKind which) { var yamp = YAMP.Parser.PrimaryContext; var mpparser = new MathParser.Parser(); var mptk = new MathParserTK_NET.MathParserTK(); var mpnet = new MathParserNet.Parser(); var mfmp = new MathFunctions.MathParser(); var llmp = new MathParserDataStructures.MathObj(); var calcEngine = new CalcEngine.CalcEngine(); calcEngine.CacheExpressions = false; var lines = new string[0]; switch (which) { case BenchmarkKind.Standard: // UB //YAMP : 154 ms //LLMP : 108 ms //MP : 4134 ms //MPTK : 375 ms //MPNET : 3054 ms //MFP : 88 ms //CALEN : 33 ms //NCALC : 420 ms lines = MakeTenK("2-3*5+7/2-8*2"); break; case BenchmarkKind.File: // UB //YAMP : 2084 ms //LLMP : 1072 ms //MP : 372847 ms //MPTK : --- //MPNET : --- //MFP : --- //CALEN : 271 ms //NCALC : --- if (!File.Exists(BMK_FILE)) { GenerateBenchmarks(); } lines = File.ReadAllLines(BMK_FILE); break; case BenchmarkKind.Little: // UB //YAMP : 71 ms //LLMP : 59 ms //MP : 1840 ms //MPTK : 87 ms //MPNET : 3232 ms //MFP : 37 ms //CALEN : 23 ms //NCALC : 247 ms lines = MakeTenK("2+3"); break; case BenchmarkKind.Thomson: // UB //YAMP : 193 ms //LLMP : 138 ms //MP : 11508 ms //MPTK : 647 ms //MPNET : 3827 ms //MFP : --- //CALEN : 41 ms //NCALC : --- lines = MakeTenK("2-(3*5)^2+7/(2-8)*2"); break; } Console.WriteLine("Starting benchmarks ..."); Console.WriteLine("----------"); // The implementation here... YAMP Benchmark("YAMP", lines, query => yamp.Run(query)); //http://www.codeproject.com/Articles/53001/LL-Mathematical-Parser Benchmark("LLMathParser", lines, query => llmp.Evaluate(query, new char[0], new double[0])); //http://www.codeproject.com/Articles/11164/Math-Parser Benchmark("MathParser", lines, query => mpparser.Evaluate(query)); //http://www.codeproject.com/Tips/381509/Math-Parser-NET-Csharp Benchmark("MathParserTK", lines, query => mptk.Parse(query, false)); //http://www.codeproject.com/Articles/274093/Math-Parser-NET Benchmark("MathParserNet", lines, query => mpnet.Simplify(query)); //http://www.codeproject.com/Articles/23061/MathParser-Math-Formula-Parser Benchmark("MathFormulaParser", lines, query => mfmp.Calculate(query)); //http://www.codeproject.com/Articles/246374/A-Calculation-Engine-for-NET Benchmark("CalcEngine", lines, query => calcEngine.Evaluate(query)); //http://ncalc.codeplex.com/ //Benchmark("NCalc", lines, query => new NCalc.Expression(query, NCalc.EvaluateOptions.NoCache).Evaluate()); }
static void RunBenchmark(BenchmarkKind which) { var yamp = new YAMP.Parser(); var mpparser = new MathParser.Parser(); var mptk = new MathParserTK_NET.MathParserTK(); var mpnet = new MathParserNet.Parser(); var mfmp = new MathFunctions.MathParser(); var llmp = new MathParserDataStructures.MathObj(); var calcEngine = new CalcEngine.CalcEngine(); calcEngine.CacheExpressions = false; var lines = new string[0]; switch (which) { case BenchmarkKind.Standard: // UB //YAMP : 154 ms //LLMP : 108 ms //MP : 4134 ms //MPTK : 375 ms //MPNET : 3054 ms //MFP : 88 ms //CALEN : 33 ms //NCALC : 420 ms lines = MakeTenK("2-3*5+7/2-8*2"); break; case BenchmarkKind.File: // UB //YAMP : 2084 ms //LLMP : 1072 ms //MP : 372847 ms //MPTK : --- //MPNET : --- //MFP : --- //CALEN : 271 ms //NCALC : --- if (!File.Exists(BMK_FILE)) GenerateBenchmarks(); lines = File.ReadAllLines(BMK_FILE); break; case BenchmarkKind.Little: // UB //YAMP : 71 ms //LLMP : 59 ms //MP : 1840 ms //MPTK : 87 ms //MPNET : 3232 ms //MFP : 37 ms //CALEN : 23 ms //NCALC : 247 ms lines = MakeTenK("2+3"); break; case BenchmarkKind.Thomson: // UB //YAMP : 193 ms //LLMP : 138 ms //MP : 11508 ms //MPTK : 647 ms //MPNET : 3827 ms //MFP : --- //CALEN : 41 ms //NCALC : --- lines = MakeTenK("2-(3*5)^2+7/(2-8)*2"); break; } Console.WriteLine("Starting benchmarks ..."); Console.WriteLine("----------"); // The implementation here... YAMP Benchmark("YAMP", lines, query => yamp.Evaluate(query)); //http://www.codeproject.com/Articles/53001/LL-Mathematical-Parser Benchmark("LLMathParser", lines, query => llmp.Evaluate(query, new char[0], new double[0])); //http://www.codeproject.com/Articles/11164/Math-Parser Benchmark("MathParser", lines, query => mpparser.Evaluate(query)); //http://www.codeproject.com/Tips/381509/Math-Parser-NET-Csharp Benchmark("MathParserTK", lines, query => mptk.Parse(query, false)); //http://www.codeproject.com/Articles/274093/Math-Parser-NET Benchmark("MathParserNet", lines, query => mpnet.Simplify(query)); //http://www.codeproject.com/Articles/23061/MathParser-Math-Formula-Parser Benchmark("MathFormulaParser", lines, query => mfmp.Calculate(query)); //http://www.codeproject.com/Articles/246374/A-Calculation-Engine-for-NET Benchmark("CalcEngine", lines, query => calcEngine.Evaluate(query)); //http://ncalc.codeplex.com/ //Benchmark("NCalc", lines, query => new NCalc.Expression(query, NCalc.EvaluateOptions.NoCache).Evaluate()); }