Re: readdir vs. getdirentriesattr
Re: readdir vs. getdirentriesattr
- Subject: Re: readdir vs. getdirentriesattr
- From: Thomas Tempelmann <email@hidden>
- Date: Mon, 29 Apr 2019 23:14:18 +0200
Quick update:
> -[enumeratorAtURL:includingPropertiesForKeys:options:errorHandler:] also
>> supports recursive enumeration (which stops at device boundaries -- you'll
>> see mount points but not their contents) so you don't have to do that
>> yourself.
>>
>
This is indeed faster than most of the other options, but, if only looking
for file names, not as fast as fts_read. When also looking at file sizes,
it's the fastest, though. Here are run times for "best case" in an APFS
volume ("/System" folder). These times come out quite similarly on repeated
runs.
*Target: /System, format: apfs*
*--- contentsOfDirectoryAtURL ---*
* 3.35s, scanned: 336991, found: 520, size: 0*
* 4.31s, scanned: 336991, found: 520, size: 9184548546*
*--- getattrlistbulk() ---*
* 3.45s, scanned: 336991, found: 520, size: 0*
* 3.50s, scanned: 336991, found: 520, size: 9184548546*
*--- readdir() ---*
* 3.05s, scanned: 336991, found: 520, size: 0*
* 8.04s, scanned: 336991, found: 520, size: 9184548546*
*--- fts ---*
* 2.32s, scanned: 336991, found: 520, size: 0*
* 2.40s, scanned: 336991, found: 520, size: 9184548546*
*--- enumeratorAtURL ---*
* 1.97s, scanned: 336991, found: 520, size: 0*
* 2.52s, scanned: 336991, found: 520, size: 9184548546*
The first of each test type looks for names only (and it extracts them from
the URL, not by getting it as a resource value like the code in
https://developer.apple.com/documentation/foundation/nsfilemanager/1409571-enumeratoraturl
suggests.
The second test also fetches the file size.
Note that on network volumes, readdir may be faster than the others,
though. Also depends on the server (Linux based NAS vs. macOS).
Thomas
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden