Pick random item based on percentages

Obligatory disclaimer: This doesn’t actually matter. Seems this post has already caused confusion, so I guess it’s necessary to explain how and why this doesn’t have any real impact.

To get the fractions of a second you’ve measured in each of these cases, you need to generate a random number multiple millions of times. Even heavy random generation (e.g. terrain generation) doesn’t generate this many random numbers (e.g. the terrain generation plugin generates 1000 random numbers up front and that’s it), so you will never encounter any noteworthy performance difference between math.random and Random in real development.

Even if you do need to generate millions of random numbers, I’m not sure a 1/100th to a 1/10th of a second difference in random generation will be noticeable? If you’re doing so many operations, other parts of those operations will matter significantly more than any difference between the random APIs. If you are discussing performance of low level data types or Roblox APIs, you are doing something wrong. The only time you should be considering performance is at an algorithmic level or when dealing with something that involves latency/web requests.

https://devforum.roblox.com/t/is-division-slower-than-multiplication/216622/19

3 Likes