Skip to content

Commit

Permalink
add cocomo to sql output
Browse files Browse the repository at this point in the history
  • Loading branch information
boyter committed May 2, 2024
1 parent 1698e28 commit d562988
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 37 deletions.
62 changes: 31 additions & 31 deletions SCC-OUTPUT-REPORT.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
<tbody><tr>
<th>Go</th>
<th>30</th>
<th>9280</th>
<th>1450</th>
<th>9298</th>
<th>1451</th>
<th>453</th>
<th>7377</th>
<th>7394</th>
<th>1513</th>
<th>394108</th>
<th>3897</th>
<th>394637</th>
<th>3912</th>
</tr><tr>
<td>processor/workers_test.go</td>
<td></td>
Expand All @@ -30,6 +30,16 @@
<td>287</td>
<td>32301</td>
<td>525</td>
</tr><tr>
<td>processor/formatters.go</td>
<td></td>
<td>1463</td>
<td>193</td>
<td>43</td>
<td>1227</td>
<td>277</td>
<td>44617</td>
<td>709</td>
</tr><tr>
<td>processor/formatters_test.go</td>
<td></td>
Expand All @@ -40,16 +50,6 @@
<td>118</td>
<td>33829</td>
<td>372</td>
</tr><tr>
<td>processor/formatters.go</td>
<td></td>
<td>1445</td>
<td>192</td>
<td>43</td>
<td>1210</td>
<td>277</td>
<td>44088</td>
<td>694</td>
</tr><tr>
<td>processor/workers.go</td>
<td></td>
Expand Down Expand Up @@ -270,16 +270,6 @@
<td>6</td>
<td>699</td>
<td>23</td>
</tr><tr>
<td>processor/helpers.go</td>
<td></td>
<td>32</td>
<td>6</td>
<td>4</td>
<td>22</td>
<td>2</td>
<td>544</td>
<td>21</td>
</tr><tr>
<td>processor/structs_test.go</td>
<td></td>
Expand All @@ -290,6 +280,16 @@
<td>4</td>
<td>517</td>
<td>19</td>
</tr><tr>
<td>processor/helpers.go</td>
<td></td>
<td>32</td>
<td>6</td>
<td>4</td>
<td>22</td>
<td>2</td>
<td>544</td>
<td>21</td>
</tr><tr>
<td>processor/processor_unix_test.go</td>
<td></td>
Expand Down Expand Up @@ -324,15 +324,15 @@
<tfoot><tr>
<th>Total</th>
<th>30</th>
<th>9280</th>
<th>1450</th>
<th>9298</th>
<th>1451</th>
<th>453</th>
<th>7377</th>
<th>7394</th>
<th>1513</th>
<th>394108</th>
<th>3897</th>
<th>394637</th>
<th>3912</th>
</tr>
<tr>
<th colspan="9">Estimated Cost to Develop (organic) $220,226<br>Estimated Schedule Effort (organic) 7.74 months<br>Estimated People Required (organic) 2.53<br></th>
<th colspan="9">Estimated Cost to Develop (organic) $220,759<br>Estimated Schedule Effort (organic) 7.75 months<br>Estimated People Required (organic) 2.53<br></th>
</tr></tfoot>
</table></body></html>
30 changes: 24 additions & 6 deletions processor/formatters.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,10 +652,12 @@ func toSqlInsert(input chan *FileJob) string {
projectName = strings.Join(DirFilePaths, ",")
}

var sumCode int64
str.WriteString("\nbegin transaction;")
count := 0
for res := range input {
count++
sumCode += res.Code

dir, _ := filepath.Split(res.Location)

Expand All @@ -675,10 +677,18 @@ func toSqlInsert(input chan *FileJob) string {
}
str.WriteString("\ncommit;")

cost, schedule, people := esstimateCostScheduleMonths(sumCode)
currentTime := time.Now()
es := float64(makeTimestampMilli()-startTimeMilli) * 0.001
str.WriteString("\nbegin transaction;")
str.WriteString(fmt.Sprintf("\ninsert into metadata values('%s', '%s', %f);", currentTime.Format("2006-01-02 15:04:05"), projectName, es))
str.WriteString(fmt.Sprintf("\ninsert into metadata values('%s', '%s', %f, %f, %f, %f);",
currentTime.Format("2006-01-02 15:04:05"),
projectName,
es,
cost,
schedule,
people,
))
str.WriteString("\ncommit;")

return str.String()
Expand Down Expand Up @@ -709,7 +719,10 @@ func toSql(input chan *FileJob) string {
str.WriteString(`create table metadata ( -- github.com/boyter/scc v ` + Version + `
timestamp text,
Project text,
elapsed_s real);
elapsed_s real,
estimated_cost real,
estimated_schedule_months real,
estimated_people real);
create table t (
Project text ,
Language text ,
Expand Down Expand Up @@ -1198,10 +1211,7 @@ func calculateCocomoSLOCCount(sumCode int64, str *strings.Builder) {
}

func calculateCocomo(sumCode int64, str *strings.Builder) {
estimatedEffort := EstimateEffort(int64(sumCode), EAF)
estimatedCost := EstimateCost(estimatedEffort, AverageWage, Overhead)
estimatedScheduleMonths := EstimateScheduleMonths(estimatedEffort)
estimatedPeopleRequired := estimatedEffort / estimatedScheduleMonths
estimatedCost, estimatedScheduleMonths, estimatedPeopleRequired := esstimateCostScheduleMonths(sumCode)

p := gmessage.NewPrinter(glanguage.Make(os.Getenv("LANG")))

Expand All @@ -1214,6 +1224,14 @@ func calculateCocomo(sumCode int64, str *strings.Builder) {
}
}

func esstimateCostScheduleMonths(sumCode int64) (float64, float64, float64) {
estimatedEffort := EstimateEffort(int64(sumCode), EAF)
estimatedCost := EstimateCost(estimatedEffort, AverageWage, Overhead)
estimatedScheduleMonths := EstimateScheduleMonths(estimatedEffort)
estimatedPeopleRequired := estimatedEffort / estimatedScheduleMonths
return estimatedCost, estimatedScheduleMonths, estimatedPeopleRequired
}

func calculateSize(sumBytes int64, str *strings.Builder) {

var size float64
Expand Down

0 comments on commit d562988

Please sign in to comment.