Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calling functions from my player event file: Performance
Author Message
Murmur
Apprentice
*

Posts: 33
Likes Given: 3
Likes Received: 2 in 2 posts
Joined: Feb 2013
Reputation: 0



Post: #1
Calling functions from my player event file: Performance
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

*you glance to your left to a region you just surveyed... you glimpse a magical being, more shadow than substance, caught midway in transformation... the figure smiles, the corners of his mouth jut upwards slightly on the edges, suddenly stretched to a length not at all human...*
(This post was last modified: 05-08-2017 08:42 AM by Murmur.)
05-08-2017 08:41 AM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 246
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #2
RE: Calling functions from my player event file: Performance
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
05-08-2017 04:41 PM
Find all posts by this user Like Post Quote this message in a reply
Coruja
Sphere Developer
*****

Posts: 987
Likes Given: 5
Likes Received: 226 in 187 posts
Joined: Jul 2012
Reputation: 7

Dimension Shard

Post: #3
RE: Calling functions from my player event file: Performance
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
(This post was last modified: 05-17-2017 01:49 PM by Coruja.)
05-17-2017 01:46 PM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)