SphereCommunity

Full Version: Calling functions from my player event file: Performance
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So I created a custom @HitTry code, it's pretty long, probably 200 lines of code, just a bunch of IF statements. The code works great. I have it set up so that if I have 200 dex, I swing weapons like a madman, like 5-10 hits per second.

Then I need to work on another part of @HitTry (my chance to hit regarding Tactics skill) and I put all my code for my swingspeed into a FUNCTION, and went ahead and tested it before I started coding anything more, and I found that instead of swinging like 5-10 times a second, I swing like 1 time a second.

So my question is about performance using functions, is there any reason that the exact same code being called from a FUNCTION would run slower that if it wasn't in function?

I would never have guessed it would, anyone have any ideas?

Thanks,
-Murmur
Performance wise, calling a code from a function it's a little more slower, but nothing to worry about.

Most probably when copy-pasting your code in to the new function you broke something Tongue
an code with 200 lines just to calculate the swing speed value on combat is already "performance-unfriendly" roflmao Big Grin

but if you're running your server on an modern CPU and doesn't call this code millions of times per second, maybe you should not be worried about it because the code will stay fast anyway

talking about milliseconds precision, "inline" codes on the same function are faster than call external functions, but if you're aiming for an lightweight code you will get better results (milliseconds) reducing these 200 lines code instead worry about use it inline or as external function
Reference URL's