Jenkins to GitHub Actions path - Time & Space Complexity
When moving from Jenkins to GitHub Actions, it is important to understand how the time to run your automation changes as your tasks grow.
We want to see how the execution time grows when running a Jenkins pipeline compared to a similar GitHub Actions workflow.
Analyze the time complexity of the following Jenkins pipeline snippet.
pipeline {
agent any
stages {
stage('Build') {
steps {
script {
for (int i = 0; i < params.NUM_STEPS; i++) {
echo "Building step ${i}"
}
}
}
}
}
}
This pipeline runs a build stage that repeats a simple echo command a number of times based on input size.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: The for-loop running the echo command.
- How many times: It runs exactly NUM_STEPS times, which depends on input size.
The number of echo commands grows directly with NUM_STEPS.
| Input Size (NUM_STEPS) | Approx. Operations (echo commands) |
|---|---|
| 10 | 10 |
| 100 | 100 |
| 1000 | 1000 |
Pattern observation: If you double NUM_STEPS, the number of echo commands doubles too.
Time Complexity: O(n)
This means the time to run grows linearly with the number of steps you want to perform.
[X] Wrong: "Adding more steps won't affect the total time much because each step is simple."
[OK] Correct: Even simple steps add up, so more steps mean more total time, growing linearly.
Understanding how your automation scales helps you design better pipelines and workflows, a skill valued in real projects and interviews.
"What if we parallelize the steps instead of running them one by one? How would the time complexity change?"