# Code Fundamentals Metrics # Churn and Efficiency

Churn is code which is deleted or rewritten shortly after being written. Read more on how to calculate churn

Formula:

Churn % = 100*(churn HALOC/total HALOC)

Churn HALOC is the number of lines of code that were churned. Total HALOC is the total lines of code

Efficiency is the percentage of code that stays in the code base compared to churn. It is rounded up to the nearest percentage.

Formula:

Efficiency % = 100-Churn% = 100*(1-(churn HALOC)/(total HALOC))

You can calculate efficiency for individuals or teams. For organization and team calculations, churn haloc is the sum of the churned lines of code for each engineer. Total HALOC is the sum of the total lines of code for each engineer.

# Commits per Active Day

Commits per active day is the average of included commits a developer submitted on days they committed.

What is an included commit?

• Commits that are not by an author who is Excluded from Reports

• Commits by someone who is a contributor on a team if you’re looking at team reports)

• Commits that are not excluded by Outlier Detection

• Commits that are not a merge commit

• Commits that are not in a deleted branch or orphaned.

Formula:

Commits per active day = sum(included commits)/sum(coding days)

You can calculate commits per active day for individuals or teams. For organization and team calculations, included commits is the sum of included commits for each engineer. Coding days is the sum of coding days for each engineer.

# Coding Days Per Week

Coding days per week  =  sum(coding days)/sum(total weeks)

A coding day is any day where a developer commits code.

Total weeks is the total number of weeks in a period irrespective of start date.  It can be calculated as # total days/7.

For organization and team calculations, coding days is the sum of the coding days of each engineer in the period. Total days is the sum of the total days for each engineer in the period.

# Impact

Impact is the severity of edits to the codebase, as compared to the repository history.

Formula:

Impact per week = sum(impact)/(total_weeks)

Total weeks is the total number of days in the period minus days during weeks where no code was committed.

Individual impact is the sum of the impact that the developer had during the period.

For Organization and Team calculations, impact is the sum of the impact for the individuals for the time. Total days is the total developer days for each engineer in the period.

# How are team averages calculated?

Let’s take a deeper look at how these formulas work for team calculations using an example.

In this example, we’ll look at impact.

Impact Formula:

Impact per week = sum(impact)/total_weeks

Let's say we have two engineers on a team. One engineer has an impact of 100 on a particular week. The other engineer has an impact of 50 on that same week. The following week, the first engineer takes some much needed PTO and therefore has an impact of 0. The second engineer has an impact of 80.

Here’s how Flow calculates the average weekly impact for that team:

1. Calculate impact. Flow sums the total impact of each team member during the time period. Here the total impact would be  100 + 50 +80 = 230.

2. Calculate total weeks. Flow then takes the sum of the total potential days each engineer could have committed code during that time period and divides it by 7. In this case, each engineer had 14 days. As a team of 2 engineers, it’s 2*14 = 28 days.

3. In this case, one engineer took the entire second week off. The total days is therefore reduced to 28-7 = 21 days, three weeks.

4. Calculate average impact per week. Flow divides the total team impact by the number of weeks found in step 3. Here, we get 230 / 3 ≅ 77 in average impact per week.