winfetch
winfetch copied to clipboard
Optimizations
This will be where I keep track of the improvements to Winfetch I make in various pull requests
How I achieve my speed improvements:
- Assume anything CIM and WMI will be slooooow and avoid it like the devil
- Use https://github.com/nohwnd/Profiler and import generated JSON files into https://www.speedscope.app/ or view results directly in PowerShell
- Shows which functions take the longest, but not what operations within the function take the longest. That takes looking into the function yourself and heavily leveraging Measure-Command
- I downclock my laptop hard (1.06 Ghz) to get more battery life out of it. But what ends up happening with PowerShell is that slow operations take a veeery long time to execute, making speed differences much more noticeable
- Use preexisting values wherever possible
- Google things a lot. Even if you think you know how to do something fast, there may be a faster or easier solution out there
Done:
- Optimized GPU fetching
- Instead of using Get-CimInstance to get GPU information, which can be very slow, gets the registry entries at 'HKLM:\SOFTWARE\Microsoft\DirectX', which contains a list of video adapters
- 1690 ms -> 40.16 ms
- 42x faster (nice)
- Made info_locale speedy
- Takes the registy entries at HKCU:Control Panel\International to get region code and language code, and passes them into two very large hash tables to get the accompanying region and language values.
- 3251 ms -> 12.43 ms
- 262x Faster
TODO:
- [ ] Attempt to optimize expensive functions
- [ ] info_ps_pkgs
- 6630 ms
- [ ] info_pkgs
- 2400 ms
- [x] info_gpu
- #155
- 1640 ms -> 40.16 ms
- 42x faster (nice)
- [ ] info_cpu_usage
- 1100 ms
- [x] info_locale
- #154
- 3251 ms -> 12.43 ms
- 262x Faster
- [ ] info_weather
- 433 ms
- Not sure there is much I can do to speed this up
- [ ] info_local_ip
- 1960 ms
- Get-NetRoute is slow
- [ ] info_ps_pkgs
- [x] Implement multithreading
- #150
- [ ] Look into incorrect resolution being reported
- #156
Speed Improvement (Excluding Multithreading): Before:
- 18715 ms
- profiler_0001.speedscope.zip
- Extract and upload to https://www.speedscope.app/ to view
After (Subtracting Speed Gains):
- 13877 ms
- 26% Faster w. everything enabled