Add bytes counter to scans (#876)

This commit is contained in:
Bill Rich 2022-10-27 12:54:22 -07:00 committed by GitHub
parent 0c81cba918
commit 034ca4fb5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View file

@ -288,6 +288,7 @@ func run(state overseer.State) {
}
}
logrus.Debugf("scanned %d chunks", e.ChunksScanned())
logrus.Debugf("scanned %d bytes", e.BytesScanned())
if *printAvgDetectorTime {
printAverageDetectorTime(e)

View file

@ -27,6 +27,7 @@ type Engine struct {
decoders []decoders.Decoder
detectors map[bool][]detectors.Detector
chunksScanned uint64
bytesScanned uint64
detectorAvgTime sync.Map
sourcesWg sync.WaitGroup
workersWg sync.WaitGroup
@ -140,6 +141,10 @@ func (e *Engine) ChunksScanned() uint64 {
return e.chunksScanned
}
func (e *Engine) BytesScanned() uint64 {
return e.bytesScanned
}
func (e *Engine) DetectorAvgTime() map[string][]time.Duration {
avgTime := map[string][]time.Duration{}
e.detectorAvgTime.Range(func(k, v interface{}) bool {
@ -163,6 +168,7 @@ func (e *Engine) DetectorAvgTime() map[string][]time.Duration {
func (e *Engine) detectorWorker(ctx context.Context) {
for originalChunk := range e.chunks {
for chunk := range sources.Chunker(originalChunk) {
atomic.AddUint64(&e.bytesScanned, uint64(len(chunk.Data)))
fragStart, mdLine := fragmentFirstLine(chunk)
for _, decoder := range e.decoders {
var decoderType detectorspb.DecoderType