How to compare numbers and performance in scripting? Any best practice tips?

  1. What do you want to achieve? Keep it simple and clear!
    I want to practice creating good habits for the future that will help improve the performance in my code.

  2. What is the issue? Include screenshots / videos if possible!
    I have been coding for a while and I still have not gotten a gist of knowing if my codes are performing well or not.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have looked on the Developer Hub, but I have only seen the ones where they give a shortcut on how to view statistics of your codes. The problem with that is I am only given the numbers without knowing the numbers’ purposes (at least from what I have seen).

There are a few practices I have done that I have seen were disconnecting threads when no longer used, using Big O notations, and avoiding using while true loops (infinite loops). I am sure there are more practices I am using, but they are not on top of my head.

I would also like to ask if there are any best practices to improve the efficiency of the script.

1 Like

Try doing time benchmarking. To do so, you will need a start time. Use os.clock as the start and end time and at the end print the difference of both.


https://devforum.roblox.com/t/what-are-some-micro-optimizations-you-know-of/1896721

1 Like

the thread you linked is about micro-optimizations, which should be the LAST thing you ever try before losing your mind. I really don’t encourage it unless you know exactly what you’re doing and all other changes/methods have failed.

Albeit it does contain some commonly known coding practices like the use of compound operators

1 Like