2 ms·
Agree re smell test. Those directory blocks are cached, even in front of a slow virtualized disk, and most of those syscalls are hitting in cache. Author is l
by loeg 5y ago
Agree re smell test. Those directory blocks are cached, even in front of a slow virtualized disk, and most of those syscalls are hitting in cache. Author is likely running into (1) stat calls and (2) buffer and sort behavior, exactly as you describe.
- iso1210 5y agoInteresting, tried myself on a test VM ~/test$ time for I in `seq -w 1 1000000`; do touch $I; done real 27m8.663s user 14m15.410s sys 12m24.411s OK ~/test$ time ls -1f | wc -l 1000002 real 0m0.604s user 0m0.180s sys 0m0.422s ~/test$ time ls -f | wc -l 1000002 real 0m0.574s ~/test$ time perl -E 'opendir(my $d,".");say while readdir $d' |wc -l 1000002 real 0m0.597s All seems reasonable. Directory size alone is 23M, somewhat larger than the typical 4096 bytes.