private static void EquationParserTest(IEnumerable <string>[] data, Dictionary <string, double> constants) { EquationParser ep = new EquationParser(); ep.SetConstants(constants); Stopwatch sw = new Stopwatch(); List <long> times = new List <long>(); for (int i = 0; i < data.Length; i++) { sw.Restart(); foreach (string exp in data[i]) { ep.Calculate(exp); } sw.Stop(); times.Add(sw.ElapsedMilliseconds); Console.WriteLine($"№{i + 1} EquationParser time: {sw.ElapsedMilliseconds} ms"); } Console.WriteLine($"EquationParser time max: {times.Max()} ms, min: {times.Min()}, average: {times.Average()}"); }
private static void EquationParserShow(int amount, int length, Dictionary <string, double> constants) { EquationParser ep = new EquationParser(); ep.SetConstants(constants); IEnumerable <string> data = TestData.Generate(10000, 20, constants.Keys); foreach (string exp in data) { double result = double.Parse(ep.Calculate(exp)); Console.WriteLine($"Expression: {exp,-150} Result: {result,-150:F2}"); } }