Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Fastest way to count # of files?
- X-seq: zsh-users 21852
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Fastest way to count # of files?
- Date: Thu, 8 Sep 2016 17:36:35 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=2CvPn8xyxVgId666pK07cz6WSYdMHFV3irFDaHfRCaA=; b=WUkeAOhTKN53P/vmvnKZy49llhJ8Yx8SRvjhd1AWWFCpFeExR/FAbXTsdiOvAy6ARp d2i2PJ1hfJwPSvwWgEBzJF0Cc4vg4MnbWDwoNBUe+gF5XMkrrdJB/QSe8QzEoKwiFHG6 qJiJONQ5ZImgtoMbhwS8kyRKJK9fdAOGHuQSlLlv5RvTd9rdOHBRL9VXXObge/UsSMMQ Er8IxrncBFmO2HMTK5RM7VhezhVNwXdECYeciW7sLX4096dM6Xt4ogNoKJycp3OMKNXZ BcoXN5c7tFHbFxa0k+wP+dxTqcfaLjVjpUaEI5jk9Oc0rkE7487zuym4RgDoERFSUAQu ybKg==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author