-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
testing/fstest: fstest.TestFS is slow when given directory contains relatively big files #69888
Comments
I think you just have a slow disk $ go test -v
=== RUN TestTestFS
=== RUN TestTestFS/testdata/many-big/big.jpg
main_test.go:32: TestFS() time: 1.640587907s
=== RUN TestTestFS/testdata/many-big/empty.txt
main_test.go:32: TestFS() time: 1.63107534s
=== RUN TestTestFS/testdata/many-big/small.txt
main_test.go:32: TestFS() time: 1.639283998s
=== RUN TestTestFS/testdata/many-small/empty.txt
main_test.go:32: TestFS() time: 252.364µs
=== RUN TestTestFS/testdata/many-small/small.txt
main_test.go:32: TestFS() time: 231.484µs
=== RUN TestTestFS/testdata/one-big/big.jpg
main_test.go:32: TestFS() time: 1.63203552s
=== RUN TestTestFS/testdata/one-empty/empty.txt
main_test.go:32: TestFS() time: 76.573µs
=== RUN TestTestFS/testdata/one-small/small.txt
main_test.go:32: TestFS() time: 202.798µs
--- PASS: TestTestFS (6.54s)
--- PASS: TestTestFS/testdata/many-big/big.jpg (1.64s)
--- PASS: TestTestFS/testdata/many-big/empty.txt (1.63s)
--- PASS: TestTestFS/testdata/many-big/small.txt (1.64s)
--- PASS: TestTestFS/testdata/many-small/empty.txt (0.00s)
--- PASS: TestTestFS/testdata/many-small/small.txt (0.00s)
--- PASS: TestTestFS/testdata/one-big/big.jpg (1.63s)
--- PASS: TestTestFS/testdata/one-empty/empty.txt (0.00s)
--- PASS: TestTestFS/testdata/one-small/small.txt (0.00s)
PASS
ok github.com/soulim/testfstest 6.547s The docs already say:
With it checking every file, it's fast if your filesystem is fast (e.g. MapFS), and slow if you have a slow filesystem. If you tested a directory of many small files that add up to the same size, it's about the same speed. I don't think any special warning is necessary for large files. |
Go version
go version go1.23.2 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
A call to
fstest.TestFS
takes significant time (seconds) to check a directory, when it contains at least one relatively big file.I've created a demo repository with a set of tests relying on
fstest.TestFS
: https://github.com/soulim/testfstest. Additionally there's a GitHub workflow that runs the same tests to demonstrate results.Setup
testdata/many-big
directory contains a set of files and one of them is big (4.4MB).testdata/many-small
directory contains a set of file, but none of them is big.testdata/one-<category>
directories contain only one file of each category: big, small, and empty.Each time when a test works with a directory containing a big file, it takes few seconds for
fstest.TestFS
to return results.What did you see happen?
An example test with
fstest.TestFS
:Output:
As you could see above it took 15 seconds for the test suite to finish. Each test is only using
fstest.TestFS
.What did you expect to see?
I did check the documentation for
fstest.TestFS
and haven't found any warning regarding working with big files.fstest.TestFS
does many checks and maybe it's expected for it to be slow with big files. However in that case, it would be nice to inform about that in the documentation.I'm more than happy to provide any additional details.
Thank you a lot for being awesome!
The text was updated successfully, but these errors were encountered: