how can I diagnose the root of the problem when my mac starts freezing for 10 sec each time I switch to an app?
I provide three techniques for diagnosing the problem. Don't miss 2 &amp; 3 below. 


I'd run etrecheck. Etrecheck will analyze your machine and
software and generate a report. Post results here so others can
view.  Experienced users have found the reported information useful
when diagnosing problems. The proprietary stuff in the report gets
filtered.


Install and run


Download etrecheck.  Goto the  EtreCheck.com download page.  The download link is at the bottom of the screen
Install etrecheck. Goto your download folder. Double click on EtreCheckPro.zip
drag the app to the application folder if you wish.
Double click on etrecheck to run.   The first five runs are free.


An alternative explanation how to install, run and report output for the EtreCheck Application by the author.
    https://discussions.apple.com/docs/DOC-11591

How to report etrecheck data.

When the report is done, click on the export icon.


click on "Copy report" to copy to the clipboard

Get back in your web browser and access your discussion. Create a new reply. Click on the &lt;> code icon. Paste you etrecheck output into the code block.

which results in...

 You may find Old Toad's write up helpful.
https://discussions.apple.com/docs/DOC-250000211


run /Applications/Utilties/Activity Monitor.  Leave it in a visible window if you can.  Maybe you can see some reason for the problem.
Try a safe boot.
Shutdown your machine.  Hold down the shift key.  Poweron.  The boot up will take longer than normal because the filesystem on the startup drive is being checked and repaired as needed.   All about safe mode including what features and apps safe boot leaves out.  Safe boot uses a software driver instead of using your machines video hardware.
  http://support.apple.com/kb/ht1455