Re: [dwm] dmenu-input

From: Jukka Salmi <j+dwm_AT_2006.salmi.ch>
Date: Thu, 5 Oct 2006 14:19:20 +0200

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?

Cheers, Jukka

-- 
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~
Received on Thu Oct 05 2006 - 14:19:21 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 14:31:51 UTC