View Full Version : Performance difference in containing multiple "scripts" in one file vs. one file per "script"

04-03-2014, 10:27 AM
Hi, I am looking into achieving the best performance with the Lua engine.

To make my question a little bit more specific, say for example I wanted to script all the bosses in Molten Core using lua, would it be best to have separate script files for every boss or would it work just as fast with having all boss scripts contained in one huge file? This is not about what is best from a workflow perspective, only the performance.

04-03-2014, 12:41 PM
Either might be fastest, only way to find out is to do a benchmark. However, in practice the difference is so small it doesn't matter; if I had to guess, it'd be less than a microsecond difference at runtime.
Just go with whatever you feel works best unless profiling says it's a bottleneck.

04-03-2014, 01:16 PM
I understand this isn't any real concern at a micro scale, however I do feel that at a macro scale when deploying over 200 scripts and many of them being used by hundreds of players(maybe even simultaneously in different instances) that this could have some effect. While that is just an imaginary scenario I also think it would be a good practice to know the optimal method from a performance perspective as well.

Also, I didn't understand why a benchmark test is the only way to find the answer to it. Maybe some of the programmers know? Thanks anyways though.

04-03-2014, 03:24 PM
If we want to talk negligible differences, then it would vary in a case by case scenario. Technically, the more files you have, the more time the engine would spend loading the scripts into memory at load, due to having to iterate through every single file. However, the larger the script file is, the longer that specific script would take to load into memory, pretty much negating the gain you got from the file loader iteration.

Thus Laureas claim pretty much stays true, the only way to actually know which is more efficient is to do a benchmark, which we have never really done as it's never been a concern, but that would also be biased as it would depend on what scripts you use and what they do. Leading back to the case by case scenario :P

04-03-2014, 04:15 PM
Alright, thank you very much, both of you!