Commit Graph

1 Commits

Author SHA1 Message Date
Giuseppe Scrivano 336611b4d0
fileutils: new functions to check for path existence
On unix they use the access syscall which is faster than stat for
simply checking the existence of a file.

with a file in the cache I see on my machine:

$ go test -bench=.
goos: linux
goarch: amd64
pkg: github.com/containers/storage/pkg/fileutils
cpu: Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
BenchmarkExists-12    	  925832	      1245 ns/op
BenchmarkStat-12      	  745896	      1602 ns/op
PASS

I'd expect even better results if the file is not already in the cache.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-04-08 16:07:26 +02:00