apt-show-versions rewrite in C++ (more than 10 times faster)

The script apt-show-versions is developed by another Debian Developer called Christoph Martin in Perl. Recently, it turned out that apt-show-versions is too slow for some users; so I decided to rewrite his program using APT’s C++ API. I expect this to be part of a future APT release, rendering the original apt-show-versions obsolete.

The rewrite is sadly not 100% backwards compatible to the original version; as some option names had to be renamed due to our command-line parser not supporting option names like -nh, and some other options were dropped because they are hard to support (like –status-file and –lists-dir) with our command-line parsing. I also decided not to keep the the -p and -r options, but use the standard APT command-line conventions insteads.

For now, it also cannot show you the distribution names you have specified in your sources.list file, but will always display codenames instead; if available. I hope to fix this in Jessie by extending APT’s cache format a bit.

On the performance side, this program now takes about 0.09s compared to the 1.40 seconds needed by apt-show-versions. The times are taken with all data in caches.

The current version can be found in a git repository, a link to gitweb is:


Please also note that support for –allversions is not 100% implemented yet, but it should work for most uses.

Now, go testing and report back!

6 thoughts on “apt-show-versions rewrite in C++ (more than 10 times faster)

  1. Wrong performance numbers?
    0.09s is about 15 times faster than 1.40 seconds, not 100 times faster.

  2. How do I compile it ?

    ~/games/apt-show-versions$ make
    g++ -Wall -Wextra -pedantic -std=c++11 -O2 -g \
    -lapt-pkg -o apt-show-versions apt-show-versions.cc
    apt-show-versions.cc:26:26: fatal error: apt-pkg/init.h: No such file or directory
    compilation terminated.
    make: *** [apt-show-versions] Error 1

  3. Thanx did it. Would be monitoring the git repo.

    $ make
    g++ -Wall -Wextra -pedantic -std=c++11 -O2 -g \
    -lapt-pkg -o apt-show-versions apt-show-versions.cc

    s$ sudo make install
    [sudo] password for shirish:
    install -D -m755 -oroot -groot apt-show-versions /usr/bin/apt-show-versions

    $ apt-show-versions -a aptitude
    aptitude install ok installed
    aptitude 0.6.3-3.2+squeeze1 stable http://ftp.debian.org
    aptitude wheezy http://ftp.debian.org
    aptitude unstable http://ftp.debian.org
    aptitude experimental http://ftp.debian.org
    aptitude/experimental uptodate

    $ apt-show-versions -a apt-show-versions
    Not installed
    apt-show-versions 0.16+squeeze1 stable http://ftp.debian.org
    apt-show-versions 0.20 wheezy http://ftp.debian.org
    apt-show-versions 0.20 unstable http://ftp.debian.org
    No experimental version
    apt-show-versions not installed

    -a allversions seems to be work🙂

Comments are closed.