public static void perf() { EnzymeDynamicContext dfp = new EnzymeDynamicContext(); var rv = new EnzymeEngine(dfp); rv.Evaluate("$total = 0"); double total = 0.0; double d = Environment.TickCount; for (int i = 0; i < 1000; i++) { total = total + 1; Console.WriteLine(total); } d = Environment.TickCount - d; double e = Environment.TickCount; for (int i = 0; i < 1000; i++) { rv.Evaluate("$total=$total+1"); Console.WriteLine(dfp.GetFieldValue("total")); } e = Environment.TickCount - e; double pf = ((e - d) / e) * 100.0; Console.WriteLine("Performance loss: {0}", pf); Console.ReadLine(); }
static void Main(string[] args) { IEnzymeContext dfp = new TestingContext(); var rv = new EnzymeEngine(dfp); StreamReader sr = new StreamReader("test.txt"); while(!sr.EndOfStream) { string pp = sr.ReadLine().Trim(); if (!string.IsNullOrEmpty(pp)) Console.WriteLine(rv.Evaluate(pp)); } }
public void EvaluateTest() { IEnzymeContext fieldsProvider = new EnzymeStaticContext(); // TODO: Initialize to an appropriate value EnzymeEngine target = new EnzymeEngine(fieldsProvider); // TODO: Initialize to an appropriate value string codeLine = "if $8 == 4+5 then 10 else 2*10"; object expected = 20.0; object actual; actual = target.Evaluate(codeLine); Assert.AreEqual(expected, actual); }
public void MoreEvalute() { IEnzymeContext fpr = new EnzymeDynamicContext(); EnzymeEngine engine = new EnzymeEngine(fpr); Debug.Print(engine.Evaluate("$r1 = 20").ToString()); Debug.Print(engine.Evaluate("$r2 = 12").ToString()); double d = (double)engine.Evaluate("$R = ($r1*$r2)/($r1+$r2)"); Assert.AreEqual(d, 7.5); }