# Change lead time

## Summary

Change lead time is one of the DORA metrics and a key deployment insight found in Swarmia. It measures the time it takes for pull requests to go from the first commit to deployment and helps you identify wait times and bottlenecks in your development process.

[Pull request cycle time](https://help.swarmia.com/pull-request-cycle-time), on the other hand, excludes the last part of the lifecycle, time to deploy, and includes only the time from the first commit to pull request merge.

Despite being related, it makes the most sense to look at pull request cycle time and deployment metrics like change lead time separately. Slow time to deploy might mask the improvements you're making in the rest of your development process.

Using two separate metrics also ensures that missing lifecycle data doesn't skew the metrics. Pull request cycle time can be calculated for all pull requests, whereas change lead time is only calculated for pull requests that belong to applications that have deployments configured in Swarmia.

If a deployment includes multiple pull requests, change lead time is calculated for each pull request. If the same pull request is deployed to multiple environments, change lead time is calculated for each deployment.

## Examples

### **Example 1**

If you have three deployments that took 2 days, 3 days, and 1.5 days from the first commit to deployment, your Change lead time would be 2.17 days.

### **Example 2**

You have two deployments to different environments, each with the same two pull requests:

* Deployment to **staging**:
  * PR **#123**
  * PR **#456**
* Deployment to **production**:
  * PR **#123**
  * PR **#456**

This will be interpreted as four *changes*, each with a Change lead time:

1. From the first commit in PR **#123** to deployment to **staging**
2. From the first commit in PR **#456** to deployment to **staging**
3. From the first commit in PR **#123** to deployment to **production**
4. From the first commit in PR **#456** to deployment to **production**

If you're viewing just these two deployments in [Deployments](https://app.swarmia.com/infrastructure/deployments), the change lead time you'll see will be the average of these four *changes*. In practice, however, we suggest filtering only the most appropriate environment for your analysis.

{% hint style="info" %}
When looking at DORA metrics for a team, they're calculated based on all the deployments that include the team's PRs. If those deployments contain PRs from other teams, that can skew your team's change lead time. Read more on [how deployments are attributed to teams](https://help.swarmia.com/use-cases/track-dora-metrics#how-deployments-are-attributed-to-teams)
{% endhint %}

## Why it matters

Change lead time is an indicator of how quickly you can ship new things to production. High change lead time can indicate too large batch sizes, slow code review/QA, or long CI/CD wait times.

## Benchmarks

* **Great**: < 24 hours
* **Good**: < 5 working days
* **Needs attention**: > 5 working days

## How to use it

Measure change lead time in combination with other deployment and DORA metrics to ensure a healthy balance of speed vs stability in your delivery.

### Setup

Change lead time is not available when using [merged pull requests](https://help.swarmia.com/getting-started/configuration/configuring-deployments-in-swarmia/generate-deployments-from-merged-pull-requests) as the deployment source. For more information, see [Deployment settings](https://help.swarmia.com/getting-started/configuration/configuring-deployments-in-swarmia).

## Where to find it

You can find change lead time (as well as the other DORA metrics) under [Infrastructure → Deployments](https://app.swarmia.com/infrastructure/deployments).
