Hello guys, for months I was facing some problem with one of my client's server, on which it would simply freezes without any abomination on bandwidth. I knew that I had peeks on main memory, but still could not locate what was causing it. Was it some distro configuration that I have implemented on the past? Or some LUA functions? Well, turns out, with an advice from
@Xikini I could monitor LUA function execution time and locate the error.
This is a simply implementation, but it turns out, I could easily see LUA functions taking up to 1000+ms on its execution time, not to much, but if consider it blocks the current thread, it turns out a lot.
For the geeks, I did the implementation using really basic structure, I did not want to globally instantiate a object to take care of the logging, because it would result in more functions calls and complexity. It would be better, but I did not want to mess up much with the code structure; I have opted for a simply class that would start counting, and on its destructor, did the real work in case time was overwhelmed. Could I maybe used some heap memory and pointers to avoid the extra memory on functions calls? hmm.. yes, but also, that would result in bad performance if not implemented correctly, nor keeping up with the memory layout itself.
Please feel free to criticize on how this basic implementation is set up, and maybe we can workout together on something more attractive.
Script.
On baseevent.h (because all the other LUA scripts functions are inheritanced from it) I created a class: