moby/pkg/fileutils
Sebastiaan van Stijn eaa9494b71
pkg/fileutils: GetTotalUsedFds: reduce allocations
Use File.Readdirnames instead of os.ReadDir, as we're only interested in
the number of files, and results don't have to be sorted.

Before:

    BenchmarkGetTotalUsedFds-5   	  149272	      7896 ns/op	     945 B/op	      20 allocs/op

After:

    BenchmarkGetTotalUsedFds-5   	  153517	      7644 ns/op	     408 B/op	      10 allocs/op

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-30 01:31:58 +02:00
..
fileutils.go pkg/fileutils: ReadSymlinkedDirectory: preserve underlying error 2022-10-16 20:15:08 +02:00
fileutils_darwin.go Add canonical import comment 2018-02-05 16:51:57 -05:00
fileutils_linux.go pkg/fileutils: GetTotalUsedFds: reduce allocations 2023-06-30 01:31:58 +02:00
fileutils_test.go pkg/fileutils: add BenchmarkGetTotalUsedFds 2023-06-30 01:31:57 +02:00
fileutils_windows.go Add canonical import comment 2018-02-05 16:51:57 -05:00