Closed josephrocca closed 2 years ago
Is there anything about the interface that is inherently slow? Also please state which filesystem you tested this on. Windows in particular has weird performance characteristics for its filesystem.
I suspect the perf problem might be because of the excessive number of promises. In my opinion, .keys() should just return an array. If a directory has so many entries that this is bad for perf, the number of promises is also likely to cause perf problems and there should be a separate API which is something like AsyncIterator<Handle[]> so that way the event loop is handling say 50 entries at a time instead of a separate loop iteration and promise per handle. According to the JS spec, new Promise(cb) can't just run cb immediately and is effectively like setTimeout(cb, 0).
I think this is a duplicate of #215
Does this API allow for a faster way of counting files in a directory than the example below?
I've been playing around with the API building a bulk file transformer/converter (demo/code) and the above method seems to be a bit slow when there are tens of thousands of files in the directory.
If operating system do track/cache this info then it would be great if it could be exposed in this API.