Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
walk: avoid stat()'ing files unnecessarily
Before: ``` go test -bench=. . goos: linux goarch: amd64 pkg: github.com/tonistiigi/fsutil cpu: Intel(R) Core(TM) i7-10610U CPU @ 1.80GHz BenchmarkWalker/[1]-target-8 27994 41254 ns/op BenchmarkWalker/[1]-**/target-8 29540 40402 ns/op BenchmarkWalker/[2]-*/target-8 1017 1104834 ns/op BenchmarkWalker/[2]-**/target-8 920 1124731 ns/op BenchmarkWalker/[3]-*/*/target-8 34 40524094 ns/op BenchmarkWalker/[3]-**/target-8 32 40432908 ns/op BenchmarkWalker/[4]-*/*/*/target-8 31 44836714 ns/op BenchmarkWalker/[4]-**/target-8 26 44611379 ns/op BenchmarkWalker/[5]-*/*/*/*/target-8 85 14179975 ns/op BenchmarkWalker/[5]-**/target-8 78 13620031 ns/op BenchmarkWalker/[6]-*/*/*/*/*/target-8 44 23380013 ns/op BenchmarkWalker/[6]-**/target-8 51 22435264 ns/op BenchmarkWalker/[6]-**-!*/*/**-8 2101 580936 ns/op ``` After: ``` go test -bench=. . goos: linux goarch: amd64 pkg: github.com/tonistiigi/fsutil cpu: Intel(R) Core(TM) i7-10610U CPU @ 1.80GHz BenchmarkWalker/[1]-target-8 40788 26219 ns/op BenchmarkWalker/[1]-**/target-8 41642 26998 ns/op BenchmarkWalker/[2]-*/target-8 1725 660271 ns/op BenchmarkWalker/[2]-**/target-8 1806 645525 ns/op BenchmarkWalker/[3]-*/*/target-8 64 17609101 ns/op BenchmarkWalker/[3]-**/target-8 66 17563334 ns/op BenchmarkWalker/[4]-*/*/*/target-8 40 26241578 ns/op BenchmarkWalker/[4]-**/target-8 43 24575370 ns/op BenchmarkWalker/[5]-*/*/*/*/target-8 121 9564283 ns/op BenchmarkWalker/[5]-**/target-8 126 9412483 ns/op BenchmarkWalker/[6]-*/*/*/*/*/target-8 63 18703020 ns/op BenchmarkWalker/[6]-**/target-8 73 17287584 ns/op BenchmarkWalker/[6]-**-!*/*/**-8 3792 273148 ns/op ``` Signed-off-by: Nick Santos <[email protected]>
- Loading branch information