Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.
New to the forum? Say hello in this topic! Also make sure to read the rules.
New to the forum? Say hello in this topic! Also make sure to read the rules.
Large script affects game performance
Forum rules
By using the forum you agree to the following rules.
By using the forum you agree to the following rules.
-
- Superfighter
- Posts: 97
- Joined: Thu Feb 07, 2019 4:36 am
Large script affects game performance
I am having a large script (~9k loc) and wondered if having a script that large will affect the game performance negatively. So I make a very large dummy script file 60Mb and 17Mb fill with just comment. The 60Mb one crashed the game as expected but the smaller one takes 20s to load every round on my full SSD laptop. The script with ~9k load like 3s slower than without any script and I am fairly certain in doesn't contain any tight loop at initialization that can affect the performance. Idk but having to reload 3s every round bother me somehow. Is there anything you can do to cache the script or something? I think the scripts are loaded and run again at every round so there maybe room for optimization here.
0 x
- JakSparro98
- Superfighter
- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 25
Unfortunately the Script editor and the sandbox system responsible for validating the script itself generates a lot of overhead, comments or unexecuted code are not a problem in standard applications even when the code is interpreted runtime because it is never all completely loaded into work memory, but in SFD every line is always parsed regardless their actual utility.
Honestly I never had the need to write more than 3k lines of code for a SFD script, apart from that 9k+ lines of code seems fine to me, is your lag experienced during game play also or only at map start/loading? If it's only at startup (and you don't have loops of all kind in startup methods) the issue here is said sandbox system parsing the code, otherwise it could even be the code itself, how many objects each loop processes on average?
Honestly I never had the need to write more than 3k lines of code for a SFD script, apart from that 9k+ lines of code seems fine to me, is your lag experienced during game play also or only at map start/loading? If it's only at startup (and you don't have loops of all kind in startup methods) the issue here is said sandbox system parsing the code, otherwise it could even be the code itself, how many objects each loop processes on average?
0 x
- Gurt
- Lead Programmer
- Posts: 1884
- Joined: Sun Feb 28, 2016 3:22 pm
- Title: Lead programmer
- Started SFD: Made it!
- Location: Sweden
- Gender:
- Age: 34
You should always avoid thight loops calling functions in the ScriptAPI each update as that would add overhead.
It sounds like it's only the startup that takes time for you. Maybe you have some code causing the slower start times. Could also just be a large map containing many tiles.
It sounds like it's only the startup that takes time for you. Maybe you have some code causing the slower start times. Could also just be a large map containing many tiles.
1 x
Gurt