Sometimes, you may want to run code all of the time. Other times, you may want
to run code some of the time. This is how garbage collection in PHP works.
Based on your configuration for
collections runs a fraction of the time (defaulting to 1/100 or 1% of the
To do something similar to this anywhere in your code, you can generate a random number between 1 and 100 and then see if it is less than or equal to a value that represents the percentage of the time you want the code to run.
There will be a small bit of deviation, but it will be close enough to get the desired results of code only running some of the time.