GitHub Actions comparison in Jenkins - Time & Space Complexity
We want to understand how the time to run Jenkins pipelines changes as we add more steps or jobs.
How does the total work grow when the pipeline gets bigger?
Analyze the time complexity of the following Jenkins pipeline snippet.
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building...'
}
}
stage('Test') {
steps {
echo 'Testing...'
}
}
stage('Deploy') {
steps {
echo 'Deploying...'
}
}
}
}
This pipeline runs three stages sequentially: Build, Test, and Deploy.
Look for repeated actions or loops in the pipeline.
- Primary operation: Each stage runs once in order.
- How many times: Number of stages (3 here, but can grow).
As we add more stages, the total steps increase one by one.
| Input Size (n = stages) | Approx. Operations |
|---|---|
| 10 | 10 steps |
| 100 | 100 steps |
| 1000 | 1000 steps |
Pattern observation: The work grows directly with the number of stages.
Time Complexity: O(n)
This means if you double the number of stages, the total time roughly doubles.
[X] Wrong: "Adding more stages won't affect total time much because they run fast."
[OK] Correct: Even if each stage is quick, more stages add up linearly, increasing total time.
Understanding how pipeline steps add up helps you design efficient workflows and explain your choices clearly.
What if we ran all stages in parallel instead of sequentially? How would the time complexity change?