Hi everyone,

        In modules/dpkg.sh, the function to get the full package list 
look like this:

function package_db_view_packages {
    NUMPKG=`dpkg --list | wc -l`
    dpkg --list | awk '{ print $2 }' | tail -n `expr $NUMPKG - 5`
}

        Ummm, I would suggest changing it to the following:

function package_db_view_packages {
    dpkg --list | sed -ne '1,5!s%^..  %%p' | cut -f1 -d' '
}

        I have made some tests on a K6-II @350Mhz with around 900
packages installed and while the first options takes around 4 seconds to
run (0.350 s system time), the second one takes almost exactly half the
time (2 seconds, 0.150 system time). 

        From the several tests I have run, I have came to the
conclusion that the time it takes to run this function is heavily
conditioned by the  "dpkg --list" command, which processes the big
/var/dpkg/status file. Although at first I thought that using grep would
be faster that using awk, it seems not to make a visible difference, but
the fact that the first option calls "dpkg --list" two times makes it
half as fast as the second one, at least on my box.

        Using grep instead of awk also has the advantage that grep is
more common that awk and is installed even in very minimal systems. For
instance, in Debian, sed has priority "required", whereas mawk has
priority "base", and gawk has priority "optional".

        Perhaps, someone else should test this, using simply the shell
command "time", to verify if the second option is faster.

        This does not solve the problem with long package names and
"dpkg --list", though.


Reply via email to