However, with all these programs, I noticed that execution time seemed to take a long time on Fedora.
Why? Well I started to dig through some
neofetch source code and discovered that the default method for counting installed packages is by counting the number of lines outputted by
rpm -qa. In my testing, this operation took an average of 2 seconds.
afetch used this same method as well.
So, there’s got to be a faster way, right?
Yes. (That I have only tested with Fedora, I’m unsure of file locations on other RPM-based distributions).
Let’s query the RPM database directly with
This operation seems to take 0.02 seconds on average:
.. or about 89x faster.. hmm.
This is defnitely a neat little hack, but is probably unwise to implement in software since it’s more likely that the location of
rpmdb.sqlite will change before functionality of the
rpm package. (Although, you can try and check to see if the database exists in that location first).