private void Start()
        {
            //UserData.DefaultAccessMode = InteropAccessMode.Preoptimized;
            UserData.RegisterAssembly();

            //var nLuaState = new Lua();
            var moonSharpState = new Script();

            const string script = @"
			a = """"
			onUpdate = function(championPropertiesComponent)
				a = championPropertiesComponent:getName()
			end
		"        ;

            //nLuaState.DoString(script);
            moonSharpState.DoString(script);

            var championProperties = new ChampionPropertiesComponent();

            championProperties.SetFirstName("John");
            championProperties.SetLastName("Smith");

            //var nLuaFunction = (LuaFunction)nLuaState["onUpdate"];
            var moonSharpFunction = (Closure)moonSharpState.Globals["onUpdate"];

            int startTime, endTime;

            //// Test NLua
            //startTime = Environment.TickCount;
            //for (int i = 0; i < 100000; i++) nLuaFunction.Call(championProperties.ToInterface());
            //endTime = Environment.TickCount;
            //Console.WriteLine("NLua : {0}", endTime - startTime);

            // Test MoonSharp
            startTime = Environment.TickCount;
            //DynValue v = DynValue.FromObject(moonSharpState, championProperties.ToInterface());
            for (int i = 0; i < 100000; i++)
            {
                moonSharpFunction.Call(championProperties.ToInterface());
            }
            endTime = Environment.TickCount;
            Console.WriteLine("MoonSharp : {0}", endTime - startTime);
        }
Esempio n. 2
0
		private void Start()
		{
			//UserData.DefaultAccessMode = InteropAccessMode.Preoptimized;
			UserData.RegisterAssembly();

			//var nLuaState = new Lua();
			var moonSharpState = new Script();

			const string script = @"
			a = """"
			onUpdate = function(championPropertiesComponent)
				a = championPropertiesComponent:getName()
			end
		"; 

			//nLuaState.DoString(script);
			moonSharpState.DoString(script);

			var championProperties = new ChampionPropertiesComponent();
			championProperties.SetFirstName("John");
			championProperties.SetLastName("Smith"); 

			//var nLuaFunction = (LuaFunction)nLuaState["onUpdate"];
			var moonSharpFunction = (Closure)moonSharpState.Globals["onUpdate"];

			int startTime, endTime;

			//// Test NLua
			//startTime = Environment.TickCount;
			//for (int i = 0; i < 100000; i++) nLuaFunction.Call(championProperties.ToInterface());
			//endTime = Environment.TickCount;
			//Console.WriteLine("NLua : {0}", endTime - startTime);

			// Test MoonSharp
			startTime = Environment.TickCount;
			//DynValue v = DynValue.FromObject(moonSharpState, championProperties.ToInterface());
			for (int i = 0; i < 100000; i++) moonSharpFunction.Call(championProperties.ToInterface());
			endTime = Environment.TickCount;
			Console.WriteLine("MoonSharp : {0}", endTime - startTime);
		}