flozz / rivalcfg

CLI tool and Python library to configure SteelSeries gaming mice
https://flozz.github.io/rivalcfg/
Do What The F*ck You Want To Public License
761 stars 61 forks source link

Improve CLI startup time #193

Closed gryzus24 closed 1 year ago

gryzus24 commented 1 year ago

Program startup time was really slow. After inspecting it with -Ximporttime it turned out to be pulling in a lot of unnecessary packages from pkg_resources responsible only for debug functionality.

Solution: reduce the scope of the debug import.

Note that this type of optimization is more of a hack than a solution, but considering it significantly improves startup time for the 99%+ of use cases it is worth implementing.

Before the patch:

$ time python3.10 -m rivalcfg --help > /dev/null

real    0m0,156s
user    0m0,125s
sys 0m0,023s

After the patch:

$ time python3.10 -m rivalcfg --help > /dev/null

real    0m0,069s
user    0m0,050s
sys 0m0,011s