On Thu, Oct 05, 2006 at 02:19:20PM +0200, Jukka Salmi wrote:
> Antoni Grzymala --> dwm (2006-10-05 13:41:44 +0200):
> > Also, I think I had a much faster oneliner than arg's...
> [...]
> > $ time find /opt/texlive/2005/bin/i386-linux /home/antoni/bin /sbin
> > /usr/sbin /usr/local/bi n /usr/bin /bin /opt/bin
> > /usr/i686-pc-linux-gnu/gcc-bin/4.1.1 /opt/ati/bin /usr/kde/3.5/bin
> > /usr/qt/3/bin /usr/games/bin /opt/vmware/server/bin -maxdepth 1 -type f
> > | sort | uniq 1>/dev/null
>
> Comparing this to the shell command in config.arg.h doesn't make sense:
> the find command doesn't check whether the files are executable by the
> invoking user; the shell command does. It's a very expensive test.
>
> Comparing the commands after removing the executable bits test from
> them revealed (averages of five runs each):
>
> $ time ./dmenu-input >/dev/null
> real 0m0.003s
> user 0m0.002s
> sys 0m0.002s
>
> $ path="$(echo $PATH | sed 's/:/ /g')"
> $ time find $path -maxdepth 1 -type f >/dev/null
> real 0m0.011s
> user 0m0.001s
> sys 0m0.011s
>
> $ time sh cmd.sh >/dev/null
> real 0m0.015s
> user 0m0.015s
> sys 0m0.000s
>
> $ cat cmd.sh
> IFS=:;
> for dir in $PATH; do
> for file in "$dir"/*; do
> # [ -x "$file" ] && echo "${file##*/}";
> echo "${file##*/}";
> done;
> done
>
> Hmm, how many times do I have to use dmenu-input instead of the shell
> command to save more time than I spent doing these test and writing
> this mail?
If invoking the command in my config.h is a performance issue
for anyone, cache the output somewhere and use this instead of
invoking my command. I bet nothing will beat:
`dmenu < proglist.cache`
Regards,
-- Anselm R. Garbe ><>< www.ebrag.de ><>< GPG key: 0D73F361Received on Thu Oct 05 2006 - 14:33:43 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 14:31:51 UTC