zsh-users
 help / color / mirror / code / Atom feed
* Fastest way to count # of files?
@ 2016-09-08 15:36 Sebastian Gniazdowski
  2016-09-08 16:08 ` Bart Schaefer
  0 siblings, 1 reply; 7+ messages in thread
From: Sebastian Gniazdowski @ 2016-09-08 15:36 UTC (permalink / raw)
  To: Zsh Users

Hello,
I'm trying to protect from slow NFS hierarchies and large directory
tries. This is fast:

% typeset -F SECONDS; myst=$SECONDS; arr=( *rarestring(NY1) ); echo
$(( (SECONDS - myst) * 1000 ))
80.286000000342028


this is slow:

% typeset -F SECONDS; myst=$SECONDS; arr=( * ); echo ${#arr}; echo $((
(SECONDS - myst) * 1000 ))
1154.1240000005928


First code obviously has to read every file in directory. But it's
doing this fast. The second code reads the whole directory too, but
it's slow. First code doesn't provide way to determine # of files
read. Is there anything between these two? Something that doesn't
store files, but counts them?

Best regards,
Sebastian Gniazdowski


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-09-09 16:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-08 15:36 Fastest way to count # of files? Sebastian Gniazdowski
2016-09-08 16:08 ` Bart Schaefer
2016-09-08 16:37   ` Sebastian Gniazdowski
2016-09-08 20:00     ` Bart Schaefer
2016-09-09  1:09       ` Bart Schaefer
     [not found]       ` <160908180958.ZM14692__14483.1264777624$1473385001$gmane$org@torch.brasslantern.com>
2016-09-09  5:36         ` Daniel Shahaf
2016-09-09 16:31           ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).