Skip to content

Commit ef7c27c

Browse files
authored
fix: fix CountStats performance (boyter#626)
1 parent 5e1bfbc commit ef7c27c

File tree

2 files changed

+45
-33
lines changed

2 files changed

+45
-33
lines changed

SCC-OUTPUT-REPORT.html

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
<tbody><tr>
1414
<th>Go</th>
1515
<th>27</th>
16-
<th>22681</th>
16+
<th>22693</th>
1717
<th>1431</th>
18-
<th>430</th>
19-
<th>20820</th>
20-
<th>1359</th>
21-
<th>438710</th>
22-
<th>6146</th>
18+
<th>434</th>
19+
<th>20828</th>
20+
<th>1363</th>
21+
<th>438928</th>
22+
<th>6148</th>
2323
</tr><tr>
2424
<td>processor/constants.go</td>
2525
<td></td>
@@ -63,13 +63,13 @@
6363
</tr><tr>
6464
<td>processor/workers.go</td>
6565
<td></td>
66-
<td>822</td>
66+
<td>834</td>
6767
<td>124</td>
68-
<td>91</td>
69-
<td>607</td>
70-
<td>201</td>
71-
<td>25179</td>
72-
<td>489</td>
68+
<td>95</td>
69+
<td>615</td>
70+
<td>205</td>
71+
<td>25397</td>
72+
<td>492</td>
7373
</tr><tr>
7474
<td>processor/processor.go</td>
7575
<td></td>
@@ -250,16 +250,6 @@
250250
<td>0</td>
251251
<td>2209</td>
252252
<td>35</td>
253-
</tr><tr>
254-
<td>processor/bloom.go</td>
255-
<td></td>
256-
<td>37</td>
257-
<td>7</td>
258-
<td>12</td>
259-
<td>18</td>
260-
<td>2</td>
261-
<td>1062</td>
262-
<td>29</td>
263253
</tr><tr>
264254
<td>processor/cocomo_test.go</td>
265255
<td></td>
@@ -270,6 +260,16 @@
270260
<td>6</td>
271261
<td>686</td>
272262
<td>23</td>
263+
</tr><tr>
264+
<td>processor/bloom.go</td>
265+
<td></td>
266+
<td>37</td>
267+
<td>7</td>
268+
<td>12</td>
269+
<td>18</td>
270+
<td>2</td>
271+
<td>1062</td>
272+
<td>29</td>
273273
</tr><tr>
274274
<td>processor/helpers_test.go</td>
275275
<td></td>
@@ -294,15 +294,15 @@
294294
<tfoot><tr>
295295
<th>Total</th>
296296
<th>27</th>
297-
<th>22681</th>
297+
<th>22693</th>
298298
<th>1431</th>
299-
<th>430</th>
300-
<th>20820</th>
301-
<th>1359</th>
302-
<th>438710</th>
303-
<th>6146</th>
299+
<th>434</th>
300+
<th>20828</th>
301+
<th>1363</th>
302+
<th>438928</th>
303+
<th>6148</th>
304304
</tr>
305305
<tr>
306-
<th colspan="9">Estimated Cost to Develop (organic) $654,636<br>Estimated Schedule Effort (organic) 11.71 months<br>Estimated People Required (organic) 4.97<br></th>
306+
<th colspan="9">Estimated Cost to Develop (organic) $654,900<br>Estimated Schedule Effort (organic) 11.71 months<br>Estimated People Required (organic) 4.97<br></th>
307307
</tr></tfoot>
308308
</table></body></html>

processor/workers.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,10 @@ func CountStats(fileJob *FileJob) {
518518
return
519519
}
520520
}
521-
printTraceF("%s line %d ended with state: %d: counted as code", fileJob.Location, fileJob.Lines, currentState)
521+
if Trace {
522+
// Don't remove the outside if-statements, for performance
523+
printTraceF("%s line %d ended with state: %d: counted as code", fileJob.Location, fileJob.Lines, currentState)
524+
}
522525
case SComment, SMulticomment, SMulticommentBlank:
523526
fileJob.Comment++
524527
currentState = resetState(currentState)
@@ -527,23 +530,32 @@ func CountStats(fileJob *FileJob) {
527530
return
528531
}
529532
}
530-
printTraceF("%s line %d ended with state: %d: counted as comment", fileJob.Location, fileJob.Lines, currentState)
533+
if Trace {
534+
// Same as above
535+
printTraceF("%s line %d ended with state: %d: counted as comment", fileJob.Location, fileJob.Lines, currentState)
536+
}
531537
case SBlank:
532538
fileJob.Blank++
533539
if fileJob.Callback != nil {
534540
if !fileJob.Callback.ProcessLine(fileJob, fileJob.Lines, LINE_BLANK) {
535541
return
536542
}
537543
}
538-
printTraceF("%s line %d ended with state: %d: counted as blank", fileJob.Location, fileJob.Lines, currentState)
544+
if Trace {
545+
// Same as above
546+
printTraceF("%s line %d ended with state: %d: counted as blank", fileJob.Location, fileJob.Lines, currentState)
547+
}
539548
case SDocString:
540549
fileJob.Comment++
541550
if fileJob.Callback != nil {
542551
if !fileJob.Callback.ProcessLine(fileJob, fileJob.Lines, LINE_COMMENT) {
543552
return
544553
}
545554
}
546-
printTraceF("%s line %d ended with state: %d: counted as comment", fileJob.Location, fileJob.Lines, currentState)
555+
if Trace {
556+
// Same as above
557+
printTraceF("%s line %d ended with state: %d: counted as comment", fileJob.Location, fileJob.Lines, currentState)
558+
}
547559
}
548560
}
549561
}

0 commit comments

Comments
 (0)