dylanaraps / neofetch

🖼️ A command-line system information tool written in bash 3.2+
MIT License
21.9k stars 1.75k forks source link

`get_packages` consumes too much time #1842

Open SleepyBag opened 3 years ago

SleepyBag commented 3 years ago

Description

I'm using WSL2. Every time neofetch consumes 4 seconds or more to run. It seems that the function get_packages takes the most time. And in this function, the most consumption is from has function. On my machine, each failed has call takes 0.1 to 0.2 seconds to run. Maybe we should introduce some option to shortcut this feature.

Neofetch version

7.1.0

Screenshot

Config file

None

Verbose log

https://paste.ubuntu.com/p/qrk2rbzmyk/

  1. Run neofetch -vv 2> neofetchlog
  2. Upload the contents of neofetchlog to pastebin, gist or equivalent.
dylanaraps commented 3 years ago

Your log file is missing the package information. It contains no has at all.

+ get_packages
+ a=
+ [[ -n '' ]]
+ [[ -n packages ]]
++ trim ''
++ set -f
++ set --
++ printf '%s\n' ''
++ set +f
+ output=
+ [[ -n packages ]]
+ [[ -n '' ]]
+ [[ -n '' ]]
+ err 'Info: Couldn'\''t detect Packages.'

Please amend the log file.

SleepyBag commented 3 years ago

That's weird. I've upload a new version of log here in the below link:

https://paste.ubuntu.com/p/9sq7HGqGsf/

You can see that for most cases it just run type

+ has kiss
+ type -p kiss
+ has cpt-list
+ type -p cpt-list
+ has pacman-key
+ type -p pacman-key
+ has dpkg
+ type -p dpkg
+ manager=dpkg
++ dpkg --list
++ grep -c '^ii'
+ pac 1378
+ (( 1378 > 0 ))
+ managers+=("$1 (${manager})")
+ manager_string+='dpkg, '
+ has xbps-query
+ type -p xbps-query
+ has apk
+ type -p apk
+ has opkg
+ type -p opkg
+ has pacman-g2
+ type -p pacman-g2
+ has lvu
+ type -p lvu
+ has tce-status
+ type -p tce-status
+ has pkg_info
+ type -p pkg_info
+ has tazpkg
+ type -p tazpkg
+ has sorcery
+ type -p sorcery
+ has alps
+ type -p alps
+ has butch
+ type -p butch
+ has swupd
+ type -p swupd
+ has pisi
+ type -p pisi
+ has dnf
+ type -p dnf
+ has rpm
+ type -p rpm
+ [[ -f /etc/SDE-VERSION ]]
+ shopt -s nullglob
+ has brew
+ type -p brew
+ has emerge
+ type -p emerge
+ has Compile
+ type -p Compile
+ has eopkg
+ type -p eopkg
+ has crew
+ type -p crew
+ has pkgtool
+ type -p pkgtool
+ has scratch
+ type -p scratch
+ has kagami
+ type -p kagami
+ has cave
+ type -p cave
+ shopt -u nullglob
+ has kpm-pkg
+ type -p kpm-pkg
+ has guix
+ type -p guix
+ has nix-store
+ type -p nix-store
+ has pkginfo
+ type -p pkginfo