0
0
Jenkinsdevops~5 mins

GitHub Actions comparison in Jenkins - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: GitHub Actions comparison
O(n)
Understanding Time 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?

Scenario Under Consideration

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.

Identify Repeating Operations

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).
How Execution Grows With Input

As we add more stages, the total steps increase one by one.

Input Size (n = stages)Approx. Operations
1010 steps
100100 steps
10001000 steps

Pattern observation: The work grows directly with the number of stages.

Final Time Complexity

Time Complexity: O(n)

This means if you double the number of stages, the total time roughly doubles.

Common Mistake

[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.

Interview Connect

Understanding how pipeline steps add up helps you design efficient workflows and explain your choices clearly.

Self-Check

What if we ran all stages in parallel instead of sequentially? How would the time complexity change?