What is Cost Per Line of Code?
Cost Per Line of Code (CPLC) measures how much each line of source code costs to produce. It is a straightforward metric for gauging development efficiency, comparing projects, and evaluating different development approaches. While not the only measure of productivity, CPLC provides a useful data point when reviewing budgets and benchmarking teams.
How to Calculate Cost Per Line of Code
The formula is:
[\text{CPLC} = \frac{\text{Total Project Cost}}{\text{Lines of Code}}]
Where:
- Total Project Cost is the sum of all development expenses in dollars, including salaries, tools, and infrastructure
- Lines of Code is the total number of lines produced during the project
Calculation Example
Suppose a development project costs $7,500 and produces 300 lines of code:
[\text{CPLC} = \frac{7{,}500}{300} = 25]
The cost per line of code is $25.00.
Another Example
A larger project costs $120,000 and delivers 8,000 lines of code:
[\text{CPLC} = \frac{120{,}000}{8{,}000} = 15]
The cost per line of code is $15.00.
Summary Table
| Project | Total Cost | Lines of Code | Cost Per Line |
|---|---|---|---|
| Small Feature | $7,500 | 300 | $25.00 |
| Web Application | $120,000 | 8,000 | $15.00 |
| Mobile App | $250,000 | 15,000 | $16.67 |
| Enterprise System | $1,000,000 | 50,000 | $20.00 |
Beyond the Number
CPLC is a useful benchmark, but it should never be the sole metric for evaluating development work. Code quality, maintainability, test coverage, and performance all matter. A team that writes fewer, well-structured lines often delivers more value than one that produces a high volume of brittle code. Use CPLC alongside other indicators to build a complete picture of project efficiency.
You might also like: Cost of Sales Calculator, Cost Per Impression Calculator, or Retained Earnings Calculator.