CPU
In Screeps, every operation requires a certain amount of processing power to be completed. Every player has a limit of how much CPU (measured in milliseconds of thread usage) that can be used in a single tick.
Limits
The limit of CPU time depends on multiple factors. A player with a subscription starts with 30 CPU. This is then increased by 10 for every Global Controller Level that the player has. A player without a subscription is always limited to 10 CPU.
Bucket
For every tick that the limit of CPU is not consumed, the remainder is stored into a bucket. A bucket has a total capacity of 10,000 CPU. Every tick that usage exceeds the CPU limit, it is removed from the bucket. If the bucket reaches 0, and CPU usage is above limits, script execution halts. You may never use more than 500 CPU out of a bucket in a single tick.
Buckets are commonly used to combine multiple, heavier calculations to run intermittently over one or several ticks. This allows for a low average of CPU usage, with spikes to perform calculations that are then stored.
API CPU Usage
Each API method on the API Reference page lists CPU usage of the method ranging from const to High. It is generally suggested to avoid making repeated calls to methods with High CPU usage. Many employ caching as a mechanism to avoid this.