luabind getting the class metatable of a c++ object to push the obj as argument to lua function -


I noticed that one of the serious performance hits, one of my c ++ objects is Lava Function AGC such as < Pre> function luaFunc (someString) some string and print

It is very fast - less than 30ms for 100k calls

Now, I have another object Added more than 100 calls for more than 1sec to print

In this way I call it using luabind

  luabind :: call_function  (fn, myCObj, message);   

I use 0.5 seconds of the bus directly using the Luas Pacal function using this "hack" Was able to reduce:

  // This will automatically set the correct square metatable for me luabind :: globals (ln_pushstring (fn.interpreter (), message) fn.interpreter ()) ["MyCObj"] = myCObj; // my metadata lua_getglobal (fn.interpreter ()); Push my userdata obj on stack including lua_pushstring; Lua_pcall (fn.interpreter (), 2, 0,0));   

However, I think it might be faster and better - this is what I thought

  zero * pUserData = lua_newuserdata (fn .interpreter (), Psychoph (Maxclass)); PUserData = myCObj; Lua_getmetatable (fn.interpreter (), ????); Lua_setmetatable (fn.interpreter (), -2); Lua_pushstring (fn.interpreter (), message); Lua_pcall (fn.interpreter (), 2, 0,0)); Therefore, I believe that Lubynd manages some metatables for each class - but I do not know how it can be retrieved - I saw anything about "__leveled_cluster" in the source - besides - In a globals, I register my class in Luband with a user data oz.  

EDIT: I actually tracked the initial slow down issue - it was neither Lublin nor my code - I was applying a debugger to myself that was benchmarking with VS 2010 F5 - For some reason, when Macrobb's add to the lava function as an AGR - Debugger slowed down the whole process - manually run my command line program and it can be re-accepted. (I was only given this recognition due to the accident, because the same VS project was taking a 4sec instead of a fast computer 1 which was too low)

< However, I think it might be faster and better - this is what I thought it would be

Then the nking about that.

There is no guarantee that Lubind uses user data in that particular way. You certainly do not know that this is the exact size of the user's data class; It can wrap all C ++ objects in any type of container object.

In short, absolutely there is no way to know how lubinda represents a C ++ object without even seeing the source of the luband (which is the change Is subjected).

Due to the constant martial of your Mycclass in Lubind, you are working on all the possibilities, the easiest way to avoid this is to do martial only once in the object within Lua < Store using code> luabind :: object . Just make one with your interpreter and keep it around. Then use that item when you call the method. Every time you call a function to lubind, the object will not need to re-martial.

Comments