Use Readdirnames to reduce number of stats we're doing.

This commit is contained in:
Tom Wilkie
2015-12-09 17:42:36 +00:00
parent efecea3714
commit 1fcd079563
4 changed files with 47 additions and 10 deletions

View File

@@ -23,13 +23,12 @@ func NewWalker(procRoot string) Walker {
// passes one-by-one to the supplied function. Walk is only made public
// so that is can be tested.
func (w *walker) Walk(f func(Process)) error {
dirEntries, err := fs.ReadDir(w.procRoot)
dirEntries, err := fs.ReadDirNames(w.procRoot)
if err != nil {
return err
}
for _, dirEntry := range dirEntries {
filename := dirEntry.Name()
for _, filename := range dirEntries {
pid, err := strconv.Atoi(filename)
if err != nil {
continue