Skip to content

Commit a01003d

Browse files
authored
Merge pull request #298 from fschaefer/master
Add a overhead commandline flag to set the multiplier for corporate overhead. #281
2 parents 57056b4 + c4747cc commit a01003d

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ func main() {
108108
56286,
109109
"average wage value used for basic COCOMO calculation",
110110
)
111+
flags.Float64Var(
112+
&processor.Overhead,
113+
"overhead",
114+
2.4,
115+
"set the overhead multiplier for corporate overhead (facilities, equipment, accounting, etc.)",
116+
)
111117
flags.BoolVar(
112118
&processor.Cocomo,
113119
"no-cocomo",

processor/cocomo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ var projectType = map[string][]float64{
2727

2828
// EstimateCost calculates the cost in dollars applied using generic COCOMO weighted values based
2929
// on the average yearly wage
30-
func EstimateCost(effortApplied float64, averageWage int64) float64 {
31-
return effortApplied * float64(averageWage/12) * 2.4
30+
func EstimateCost(effortApplied float64, averageWage int64, overhead float64) float64 {
31+
return effortApplied * float64(averageWage/12) * overhead
3232
}
3333

3434
// EstimateEffort calculate the effort applied using generic COCOMO weighted values

processor/cocomo_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
func TestEstimateCost(t *testing.T) {
1010
eff := EstimateEffort(26)
11-
got := EstimateCost(eff, 56000)
11+
got := EstimateCost(eff, 56000, 2.4)
1212

1313
// Should be around 582
1414
if got < 580 || got > 585 {
@@ -18,7 +18,7 @@ func TestEstimateCost(t *testing.T) {
1818

1919
func TestEstimateCostManyLines(t *testing.T) {
2020
eff := EstimateEffort(77873)
21-
got := EstimateCost(eff, 56000)
21+
got := EstimateCost(eff, 56000, 2.4)
2222

2323
// Should be around 2602096
2424
if got < 2602000 || got > 2602100 {

processor/formatters.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ func fileSummarizeLong(input chan *FileJob) string {
817817

818818
if !Cocomo {
819819
estimatedEffort := EstimateEffort(int64(sumCode))
820-
estimatedCost := EstimateCost(estimatedEffort, AverageWage)
820+
estimatedCost := EstimateCost(estimatedEffort, AverageWage, Overhead)
821821
estimatedScheduleMonths := EstimateScheduleMonths(estimatedEffort)
822822
estimatedPeopleRequired := estimatedEffort / estimatedScheduleMonths
823823

@@ -992,7 +992,7 @@ func trimNameShort(summary LanguageSummary, trimmedName string) string {
992992
func calculateCocomo(sumCode int64, str *strings.Builder) {
993993
if !Cocomo {
994994
estimatedEffort := EstimateEffort(int64(sumCode))
995-
estimatedCost := EstimateCost(estimatedEffort, AverageWage)
995+
estimatedCost := EstimateCost(estimatedEffort, AverageWage, Overhead)
996996
estimatedScheduleMonths := EstimateScheduleMonths(estimatedEffort)
997997
estimatedPeopleRequired := estimatedEffort / estimatedScheduleMonths
998998

processor/processor.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ var AllowListExtensions = []string{}
145145
// AverageWage is the average wage in dollars used for the COCOMO cost estimate
146146
var AverageWage int64 = 56286
147147

148+
// Overhead is the overhead multiplier for corporate overhead (facilities, equipment, accounting, etc.)
149+
var Overhead float64 = 2.4
150+
148151
// GcFileCount is the number of files to process before turning the GC back on
149152
var GcFileCount = 10000
150153
var gcPercent = -1

0 commit comments

Comments
 (0)