kvakulo / Switcheroo

The humble incremental-search task switcher for Windows
www.switcheroo.io
GNU General Public License v3.0
778 stars 121 forks source link

Speed up AppWindow.ProcessTitle #118

Open daanzu opened 6 years ago

daanzu commented 6 years ago

AppWindow.ProcessTitle was contributing ~90+% of Switcheroo's CPU time whenever its cache was empty/invalidated, due to loading the whole fat Process object just to get the ProcessName, combined with absurdly inefficient implementations in SystemWindow.Process and Process.ProcessName. So, I implemented SystemWindow.ProcessId and SystemWindow.ProcessName directly, reducing my ~5sec time between hotkey & full display to effectively instant.

elig0n commented 6 years ago

Neat. Did you get that delay every time you pressed the hotkey or just at the first time after launch ? because 5 seconds sounds unreasonable, is your machine old ?

daanzu commented 6 years ago

@elig0n Delay happens first time after launch, and anytime after 1+ hour since last use, because the ProcessName cache entries have 1-hr eviction policy. My machine is fairly beefy, but I must confess to having a habit of keeping a possibly pathological number of windows/processes open. That just emphasized the shamefully quadratic original implementations.

BTW, I like some of your PRs; if they don't get accepted, I might have to pull them.

milnak commented 1 year ago

FYI, I integrated this change into my fork