Ok now we're getting into the serious stuff, the meat, the juice, the gold, the real deal, the thing.
This is the single most important trick for easily gaining performance for free.
It's low effort, and can save a ton of CPU.
What is it??
Compare two values: tickcount % 2 = 0 as the first condition of your big events.
Most of the time, you run stuff on every tick, but you actually don't need to do that. If you're writing code that updates an AI, checks for lots of collisions, or checks for win conditions to trigger your end screen, you actually don't need the code to react instantly to what happened.
So instead of running that code every tick, you can run it every two ticks. Hence
tickcount%2 = 0.
Hell, you can probably run it every 3 ticks, or even every 30 ticks and no one will notice.
Well... speedrunners will.
Anyway, it's a simple trick and an even simpler calculation. If you do something every 30 frames compared to doing it on every frame, then that thing will be 30 times less heavy on your CPU.
Congrats, you have optimized your code.
Also works with "Every X seconds" but keep in mind that this is time scale dependent and will run slower or faster if you change the time scale.