At an unfortunate moment (Link: 1, 2, 3, 4), I also fell into that group of people whose operating system was accidentally updated by Apple from macOS Monterey to the latest macOS Sonoma against their consent. :-(
Since my system fell a bit "naturally" slow after this OS update, I started to observe what was consuming the most CPU resources on my machine and soon found the problem which was a certain function of a specific application.
With the new operating system, my old machine is not as fast as it was earlier but at least I managed to find a big "hidden" CPU consumer process.
Based on this monitoring process, I made a CLI shell script, which I still use sometimes to check if something is using extra WindowServer resources.