Build triggers configuration in GCP - Time & Space Complexity
When setting up build triggers in Google Cloud, it's important to understand how the number of triggers affects the time it takes to process build events.
We want to know how the system's work grows as we add more triggers.
Analyze the time complexity of the following operation sequence.
gcloud beta builds triggers create github \
--name="trigger-1" \
--repo-name="my-repo" \
--branch-pattern="^main$" \
--build-config="cloudbuild.yaml"
gcloud beta builds triggers create github \
--name="trigger-2" \
--repo-name="my-repo" \
--branch-pattern="^dev$" \
--build-config="cloudbuild.yaml"
This sequence creates two build triggers that start builds when code is pushed to specific branches.
- Primary operation: Creating a build trigger via API call.
- How many times: Once per trigger created.
Each new trigger requires one API call to create it. So, as the number of triggers grows, the total API calls grow at the same rate.
| Input Size (n) | Approx. API Calls/Operations |
|---|---|
| 10 | 10 API calls |
| 100 | 100 API calls |
| 1000 | 1000 API calls |
Pattern observation: The number of API calls increases directly with the number of triggers.
Time Complexity: O(n)
This means the time to create triggers grows linearly with how many triggers you add.
[X] Wrong: "Creating multiple triggers happens all at once, so time stays the same no matter how many triggers."
[OK] Correct: Each trigger creation is a separate API call, so more triggers mean more calls and more time overall.
Understanding how operations scale with input size helps you design efficient cloud workflows and shows you can think about system behavior beyond just writing code.
"What if we batch create triggers in a single API call? How would the time complexity change?"