Skip to content

Commit

Permalink
CPU-based worker count for inspect (#1)
Browse files Browse the repository at this point in the history
* Squeezed a bit more speed out of the inspect method w cpu count-based workers

* Removed buffer on jobs

* seperated dep install from benchmark run in action
  • Loading branch information
brittonhayes authored Dec 9, 2020
1 parent 94df3d2 commit ca4d34e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ jobs:
os: [ macos-latest, ubuntu-latest, windows-latest ]
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: go get ./...
- name: Run benchmarks
run: go test -bench . -benchmem ./...
4 changes: 3 additions & 1 deletion pkg/hunter/hunter.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"log"
"os"
"regexp"
"runtime"
"sync"
)

Expand Down Expand Up @@ -84,8 +85,9 @@ func (h Hunter) Inspect(path string, fs afero.Fs) {
if err != nil {
panic(err)
}

defer f.Close()
for w := 1; w <= 10; w++ {
for w := 1; w <= runtime.NumCPU(); w++ {
wg.Add(1)
go h.matchPattern(jobs, results, wg)
}
Expand Down

0 comments on commit ca4d34e

Please sign in to comment.