Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bytes counter to scans #876

Merged
merged 1 commit into from Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions main.go
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions pkg/engine/engine.go
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down