public void Test_CallFunction() { functions.LoadScript(testCode1, "TestClass1"); double value = functions.Call <double>("test_func0"); Assert.AreEqual(42.0, value); }
public void CompareLUAvsCSharp() { bool resultCSharp = csharpFunctions.LoadScript(ReplaceQuotes(testCSharp), "FurnitureFunctions"); bool resultLua = luaFunctions.LoadScript(ReplaceQuotes(testLUA), "PowerGen"); Assert.IsTrue(resultCSharp); Assert.IsTrue(resultLua); int iterations = 1000; List <string> cache = new List <string>(iterations * 2); Stopwatch sw1 = new Stopwatch(); sw1.Start(); for (int i = 0; i < iterations; i++) { cache.Add(csharpFunctions.Call <string>("PowerCellPress_StatusInfo", new Furniture())); } sw1.Stop(); Stopwatch sw2 = new Stopwatch(); sw2.Start(); for (int i = 0; i < iterations; i++) { cache.Add(luaFunctions.Call <string>("PowerGenerator_FuelInfo", new Furniture())); } sw2.Stop(); UnityDebugger.Debugger.Log(string.Format("Iterations: {0}", cache.Count / 2)); UnityDebugger.Debugger.Log(string.Format("CSharp calls: {0} ms", sw1.ElapsedMilliseconds)); UnityDebugger.Debugger.Log(string.Format("LUA calls: {0} ms", sw2.ElapsedMilliseconds)); }