Throttling Macro Execution

Sometimes I want to limit how often a macro can be executed. Is there a preferred method for doing this?

For longer periods, I use a global variable. For example, if I want to only allow a macro to be triggered once within 30 minutes, I check and set a global variable like: my_macro_last_execution_time

For very short periods (like, less than a few seconds), I use a semaphore.